Robot secondaire
Dependencies: RoboClaw mbed StepperMotor
Fork of RoboClaw by
Diff: Odometry/Odometry.cpp
- Revision:
- 73:538d6627ae2f
- Parent:
- 69:1b257fb65281
- Child:
- 76:a862cb10559c
--- a/Odometry/Odometry.cpp Thu May 05 05:36:01 2016 +0200 +++ b/Odometry/Odometry.cpp Thu May 05 05:48:00 2016 +0200 @@ -158,17 +158,19 @@ //pos_prog++; //logger.printf("Dist : %3.2f\n\r", distance); //arrived = false; + bool avant = distance >= 0 ? true: false; int32_t pos_initiale_right = m_pulses_right, pos_initiale_left = m_pulses_left; 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); + roboclaw.SpeedAccelDeccelPositionM1M2(accel_dista, avant ? vitesse_dista : 0 - vitesse_dista, deccel_dista, distance_ticks_right, accel_dista, avant ? vitesse_dista : 0 - vitesse_dista, deccel_dista, distance_ticks_left, 1); //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); + 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);