Robot team project

Dependencies:   QEI Motordriver ros_lib_melodic

Files at this revision

API Documentation at this revision

Comitter:
florine_van
Date:
Mon Jan 06 15:37:11 2020 +0000
Parent:
23:d1dc248b4e54
Commit message:
Correct issue on random generation number;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r d1dc248b4e54 -r 4d6ff25fb9cc main.cpp
--- a/main.cpp	Mon Jan 06 14:55:03 2020 +0000
+++ b/main.cpp	Mon Jan 06 15:37:11 2020 +0000
@@ -159,14 +159,16 @@
     for (int i =0; i<10; i++)
     {
         int distance  = (rand()%7000+2000);
-        float A_speed = (rand()%2-1);
-        float B_speed = (rand()%2-1);
-/*        if((A_speed < 0.4) && (A_speed > -0.4)){
+        double A_speed = (double(rand()) / (double(RAND_MAX)))*2-1;
+        double B_speed = (double(rand()) / (double(RAND_MAX)))*2-1;
+        
+        if((A_speed < 0.4) && (A_speed > -0.4)){
             A_speed = 0.4;
             }
         if((B_speed < 0.4) && (B_speed > -0.4)){
             B_speed = 0.4;
-            } */
+            } 
+            
         move(A_speed,B_speed,distance);
         wheel_B.reset();
         wheel_A.reset();