Robot team project
Dependencies: QEI Motordriver ros_lib_melodic
Diff: main.cpp
- Revision:
- 24:4d6ff25fb9cc
- Parent:
- 23:d1dc248b4e54
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();