![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Tachinit
Dependencies: mbed Tach ContinuousServo
Revision 2:35bc9b7f5756, committed 2019-04-23
- Comitter:
- m215910
- Date:
- Tue Apr 23 15:45:32 2019 +0000
- Parent:
- 1:66d0178e8f40
- Commit message:
- changes still not right
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Apr 23 15:10:54 2019 +0000 +++ b/main.cpp Tue Apr 23 15:45:32 2019 +0000 @@ -10,7 +10,7 @@ //speed float wL, wR; -float x = 0.2, y = 0.2, dist, realdist; +float x = 0.2, y = -0.2, dist, realdist; ContinuousServo left(p23); ContinuousServo right(p26); @@ -29,9 +29,7 @@ while(1) { left.speed(x); - right.speed(-y); //right negative to go forward - x = x; - y = y; + right.speed(y); //right negative to go forward wL = tleft.getSpeed(); //speed of left wheel (rev/sec) wR = tright.getSpeed(); //speed of right wheel (rev/sec) @@ -39,23 +37,24 @@ realdist = dist/0.00277; if (wL<wR) { - x = x+0.03; + x = x+0.01; y = y; } else if (wR<wL) { - x = x; - y = y+0.03;} + x = x-0.01; + y = y;} else if (wR == wL) { x = x; y = y;} - else if ((x || y) > 0.2) { - x = 0.2; + + if ((x > 0.3) || (y < -0.3)) { + x = 0.3; y = y;} if (realdist <= 8) { left.stop(); right.stop(); } - pc.printf("%f, %f\n %f\n %f %f\n", wL, wR, realdist, x, y); + pc.printf("%f, %f, %f, %f, %f\n", wL, wR, realdist, x, y); wait(.2);