![](/media/cache/profiles/ebb9a55061af33b68d38f7ce72e4460f.50x50_q85.jpg)
David's dead reckoning code for the LVBots competition on March 6th. Uses the mbed LPC1768, DRV8835, QTR-3RC, and two DC motors with encoders.
Dependencies: PololuEncoder Pacer mbed GeneralDebouncer
Diff: main.cpp
- Revision:
- 22:44c032e59ff5
- Parent:
- 21:c279c6a83671
- Child:
- 23:aae5cbe3b924
diff -r c279c6a83671 -r 44c032e59ff5 main.cpp --- a/main.cpp Thu Feb 27 23:20:34 2014 +0000 +++ b/main.cpp Fri Feb 28 00:16:49 2014 +0000 @@ -43,6 +43,7 @@ //testButtons(); //testDriveHome(); //testFinalSettleIn(); + testCalibrate(); // Real routines for the contest. setLeds(1, 0, 0, 0); @@ -167,17 +168,17 @@ int32_t reduction = reckoner.sin / (1<<15) * straightDriveStrength / (1 << 15); if (reduction > 0) { - speedRight = reduceSpeed(speedRight, -reduction); + speedRight = reduceSpeed(speedRight, reduction); } else { - speedLeft = reduceSpeed(speedLeft, reduction); + speedLeft = reduceSpeed(speedLeft, -reduction); } motorsSpeedSet(speedLeft, speedRight); if (goodCalibration) { - if(goodCalibrationTimer.read_us() >= 300000) + if(goodCalibrationTimer.read_ms() >= 300) { // The calibration was good and we traveled for a bit of time after that, // so we must be a bit over the line.