mirror of
https://github.com/modelec/odo_STM32.git
synced 2026-01-18 16:27:25 +01:00
pidS fonctionnelS pour de la ligne droite
This commit is contained in:
@@ -62,8 +62,8 @@ void determinationCoefPosition(Point objectifPoint, Point pointActuel, PidPositi
|
|||||||
|
|
||||||
|
|
||||||
pid.setConsignePositionFinale(objectifPoint);
|
pid.setConsignePositionFinale(objectifPoint);
|
||||||
//std::array<double, 2> vitesse = pid.updateNouvelOrdreVitesse(pointActuel, vitGauche, vitDroit);
|
std::array<double, 2> vitesse = pid.updateNouvelOrdreVitesse(pointActuel, vitGauche, vitDroit);
|
||||||
std::array<double, 2> vitesse = {0.05,0.05};
|
//std::array<double, 2> vitesse = {0.05,0.05};
|
||||||
|
|
||||||
char debug_msg[128];
|
char debug_msg[128];
|
||||||
sprintf(debug_msg, "[CONS] G: %.3f m/s | D: %.3f m/s\r\n", vitesse[0], vitesse[1]);
|
sprintf(debug_msg, "[CONS] G: %.3f m/s | D: %.3f m/s\r\n", vitesse[0], vitesse[1]);
|
||||||
@@ -121,6 +121,19 @@ void ModelecOdometrySetup(void **out_pid, void **out_pidG, void **out_pidD) {
|
|||||||
//motor.accelerer(300);
|
//motor.accelerer(300);
|
||||||
|
|
||||||
*out_pid = new PidPosition(
|
*out_pid = new PidPosition(
|
||||||
|
0.8, // kp — un poil plus agressif, il pousse plus vers la cible
|
||||||
|
0.0, // ki — toujours off pour éviter du dépassement imprévu
|
||||||
|
0.015, // kd — un peu moins de freinage anticipé
|
||||||
|
|
||||||
|
0.5, // kpTheta — peut rester soft pour éviter les oscillations d’orientation
|
||||||
|
0.0, // kiTheta
|
||||||
|
0.15, // kdTheta — un peu moins de frein sur la rotation
|
||||||
|
Point()
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
*out_pid = new PidPosition(
|
||||||
0.6, // kp — réduit pour adoucir la réaction
|
0.6, // kp — réduit pour adoucir la réaction
|
||||||
0.0, // ki — on évite encore pour l’instant
|
0.0, // ki — on évite encore pour l’instant
|
||||||
0.03, // kd — un peu de dérivée pour stabiliser
|
0.03, // kd — un peu de dérivée pour stabiliser
|
||||||
@@ -131,6 +144,8 @@ void ModelecOdometrySetup(void **out_pid, void **out_pidG, void **out_pidD) {
|
|||||||
Point()
|
Point()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
//*out_pid = new PidPosition(1.2,0.02,0.8,0, 0, 0, Point());
|
//*out_pid = new PidPosition(1.2,0.02,0.8,0, 0, 0, Point());
|
||||||
*out_pidG = new PidVitesse(0.2, 0.0, 0.01, 0);
|
*out_pidG = new PidVitesse(0.2, 0.0, 0.01, 0);
|
||||||
*out_pidD = new PidVitesse(0.2, 0.0, 0.01, 0);
|
*out_pidD = new PidVitesse(0.2, 0.0, 0.01, 0);
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ std::array<double, 2> PidPosition::updateNouvelOrdreVitesse(Point pointActuel, f
|
|||||||
sprintf(log, "[SET] VITESSE SORTIE DE PID POS | G: %.3f m/s | D: %.3f m/s\r\n", vitesseGauche, vitesseDroite);
|
sprintf(log, "[SET] VITESSE SORTIE DE PID POS | G: %.3f m/s | D: %.3f m/s\r\n", vitesseGauche, vitesseDroite);
|
||||||
CDC_Transmit_FS((uint8_t*)log, strlen(log));
|
CDC_Transmit_FS((uint8_t*)log, strlen(log));
|
||||||
|
|
||||||
if (fabs(erreurAvant) < 0.05 && fabs(erreurLat) < 0.05 && fabs(erreurPosition.getTheta()) < 0.5) {
|
if (fabs(erreurAvant) < 0.005 && fabs(erreurLat) < 0.005 && fabs(erreurPosition.getTheta()) < 0.5) {
|
||||||
sprintf(log, "[PID] OBJECTIF ATTEINT — Robot à l'arrêt\r\n");
|
sprintf(log, "[PID] OBJECTIF ATTEINT — Robot à l'arrêt\r\n");
|
||||||
CDC_Transmit_FS((uint8_t*)log, strlen(log));
|
CDC_Transmit_FS((uint8_t*)log, strlen(log));
|
||||||
return {0.0, 0.0};
|
return {0.0, 0.0};
|
||||||
|
|||||||
Reference in New Issue
Block a user