Robot secondaire
Dependencies: RoboClaw mbed StepperMotor
Fork of RoboClaw by
Diff: Odometry/Odometry.cpp
- Revision:
- 77:f19cc7f81f2a
- Parent:
- 49:5e2f7323f280
--- a/Odometry/Odometry.cpp Wed May 04 16:15:13 2016 +0000 +++ b/Odometry/Odometry.cpp Thu May 05 08:46:08 2016 +0000 @@ -92,7 +92,9 @@ double dist_ = sqrt(carre(x_goal-x)+carre(y_goal-y)); logger.printf("Dist : %3.2f\tTheta : %3.2f\n\r", dist_, theta_*180/PI); GotoThet(theta_); + logger.printf("J'ai fais theta je suis pas trop un fdp\n\r"); GotoDist(dist_); + logger.printf("J'ai fais Dist je suis pas trop un fdp\n\r"); } void Odometry::GotoXYT(double x_goal, double y_goal, double theta_goal) @@ -110,7 +112,6 @@ //pos_prog++; //logger.printf("Theta : %3.2f\n\r", theta_*180/PI); //arrived = false; - int32_t distance_ticks_left; int32_t distance_ticks_right; @@ -140,12 +141,17 @@ //logger.printf("IniR:%6d\tDistR:%6d\tIniL:%6d\tDistL:%6d\n\r", pos_initiale_right, distance_ticks_right, pos_initiale_left, distance_ticks_left); - while((m_pulses_right != distance_ticks_right)&&(m_pulses_left != distance_ticks_left)) - logger.printf ("[Thet] %d\t%d\n\r", m_pulses_right - distance_ticks_right, m_pulses_left - distance_ticks_left); + while(abs(m_pulses_right - distance_ticks_right) >= 1 && abs(m_pulses_left - distance_ticks_left) >= 1) { + if (SDevant && SHomologation) { + roboclaw.SpeedAccelM1M2(accel_dista, 0, 0); + while(1); + } + } + //logger.printf ("[Thet] %d\t%d\n\r", m_pulses_right - distance_ticks_right, m_pulses_left - distance_ticks_left); //logger.printf("%6d\t%6d\t%6d\t%6d\t%6d\n\r",m_pulses_right - pos_initiale_right, distance_ticks_right, m_pulses_left - pos_initiale_left, distance_ticks_left); wait(0.4); - setTheta(theta_); + theta = theta_; //arrived = true; //logger.printf("arrivey %d\n\r",pos_prog); } @@ -160,12 +166,21 @@ int32_t distance_ticks_right = (int32_t) distance/m_distPerTick_right + pos_initiale_right; int32_t distance_ticks_left = (int32_t) distance/m_distPerTick_left + pos_initiale_left; - - roboclaw.SpeedAccelDeccelPositionM1M2(accel_dista, vitesse_dista, deccel_dista, distance_ticks_right, accel_dista, vitesse_dista, deccel_dista, distance_ticks_left, 1); - + logger.printf("Je suis un fdp a l'envoi d'une commande 1 !\n\r"); + if (distance >= 0) + roboclaw.SpeedAccelDeccelPositionM1M2(accel_dista, vitesse_dista, deccel_dista, distance_ticks_right, accel_dista, vitesse_dista, deccel_dista, distance_ticks_left, 1); + else + roboclaw.SpeedAccelDeccelPositionM1M2(accel_dista, -vitesse_dista, deccel_dista, distance_ticks_right, accel_dista, -vitesse_dista, deccel_dista, distance_ticks_left, 1); + logger.printf("J'suis un fdp 2\n\r"); //logger.printf("IniR:%6d\tDistR:%6d\tIniL:%6d\tDistL:%6d\n\r", pos_initiale_right, distance_ticks_right, pos_initiale_left, distance_ticks_left); - while((m_pulses_right != distance_ticks_right)&&(m_pulses_left != distance_ticks_left)); //logger.printf("PR:%6d\tIR:%6d\tDR:%6d\tPL:%6d\tIL:%6d\tDL:%6d\n\r",m_pulses_right, pos_initiale_right, distance_ticks_right, m_pulses_left, pos_initiale_left, distance_ticks_left); + while(abs(m_pulses_right - distance_ticks_right) >= 1 && abs(m_pulses_left - distance_ticks_left) >= 1) //logger.printf("PR:%6d\tIR:%6d\tDR:%6d\tPL:%6d\tIL:%6d\tDL:%6d\n\r",m_pulses_right, pos_initiale_right, distance_ticks_right, m_pulses_left, pos_initiale_left, distance_ticks_left); + { + if (SDevant && SHomologation) { + roboclaw.SpeedAccelM1M2(accel_dista, 0, 0); + while(1) ; + } + } wait(0.4); //logger.printf("arrivey %d\n\r",pos_prog); //logger.printf("X : %3.2f\tY : %3.2f\tTheta : %3.2f\n\r", getX(), getY(), getTheta()*180/PI);