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:
- 46:df2c2d25c070
- Parent:
- 45:81dd782bc0b4
- Child:
- 47:9773dc14c834
--- a/main.cpp Sun Jul 28 01:52:34 2019 +0000 +++ b/main.cpp Sun Jul 28 22:20:12 2019 +0000 @@ -61,31 +61,29 @@ //testL3gAndShowAverage(); //testTurnSensor(); //testReckoner(); + //testCloseness(); // didn't do it in 2019 //testDriveHome(); //testFinalSettleIn(); // doesn't really work //testLineSensorsAndCalibrate(); - testLineFollowing(); - //testTurnInPlace(); - //testCloseness(); - //testLogger(); - - loadLineCalibration(); - doGyroCalibration(); + //testLineFollowing(); + //testTurnInPlace(); // didn't do it in 2019 + //testLogger(); // didn't do it in 2019 doDeadReckoning(); } void doDeadReckoning() { + loadLineCalibration(); + doGyroCalibration(); + turnSensor.start(); + setLeds(1, 0, 0, 0); waitForSignalToStart(); setLeds(0, 1, 0, 0); findLine(); - //setLeds(1, 1, 0, 0); - //turnRightToFindLine(); - setLeds(0, 0, 1, 0); followLineToEnd(); @@ -225,6 +223,7 @@ updateReckoner(); } reckoner.reset(); + turnSensor.reset(); while(button1DefinitelyPressed()) { updateReckoner(); @@ -289,24 +288,6 @@ } } -/** -void turnRightToFindLine() -{ - while(1) - { - lineTracker.read(); - lineTracker.updateCalibration(); - updateReckonerFromEncoders(); - - if(lineTracker.getLineVisible()) - { - break; - } - - motorsSpeedSet(300, 100); - } -}**/ - void followLineToEnd() { Timer timer;