Robot secondaire

Dependencies:   RoboClaw mbed StepperMotor

Fork of RoboClaw by Simon Emarre

Revision:
34:e5500418b0e7
Parent:
32:068bd2b2e1f3
--- a/Odometry/Odometry.cpp	Tue Jan 26 17:02:41 2016 +0000
+++ b/Odometry/Odometry.cpp	Tue Jan 26 17:17:52 2016 +0000
@@ -169,3 +169,24 @@
     //pc.printf("arrivey %d\n\r",pos_prog);
     //pc.printf("X : %3.2f\tY : %3.2f\tTheta : %3.2f\n\r", getX(), getY(), getTheta()*180/PI);
 }
+
+void Odometry::TestEntraxe(int i) {
+    int32_t distance_ticks_left;
+    int32_t distance_ticks_right;
+
+    int32_t pos_initiale_right = m_pulses_right, pos_initiale_left = m_pulses_left;
+
+    double erreur_theta = 2*PI*i - getTheta();
+    if(erreur_theta < 0) {
+        distance_ticks_left = (int32_t) pos_initiale_left + (erreur_theta*m_v/2)/m_distPerTick_left;
+        distance_ticks_right = (int32_t) pos_initiale_right - (erreur_theta*m_v/2)/m_distPerTick_right;
+    } else {
+        distance_ticks_left = (int32_t) pos_initiale_left + (erreur_theta*m_v/2)/m_distPerTick_left;
+        distance_ticks_right = (int32_t) pos_initiale_right - (erreur_theta*m_v/2)/m_distPerTick_right;
+    }
+    
+    roboclaw.SpeedAccelDeccelPositionM1M2(ADR, accel_angle, vitesse_angle, deccel_angle, distance_ticks_right, accel_angle, vitesse_angle, deccel_angle, distance_ticks_left, 1);
+    
+    while((m_pulses_right != distance_ticks_right)&&(m_pulses_left != distance_ticks_left)); 
+    wait(0.4);
+}
\ No newline at end of file