David's line following code from the LVBots competition, 2015.

Dependencies:   GeneralDebouncer Pacer PololuEncoder mbed

Fork of DeadReckoning by David Grayson

Committer:
DavidEGrayson
Date:
Sun Feb 23 23:49:58 2014 +0000
Revision:
13:bba5b3abd13f
Parent:
12:835a4d24ae3b
Child:
21:c279c6a83671
testReckoner routine works great!  I can roll my robot around and it always knows what quadrant it is pointing to and knows what quadrant it is in!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DavidEGrayson 12:835a4d24ae3b 1 class Reckoner
DavidEGrayson 12:835a4d24ae3b 2 {
DavidEGrayson 12:835a4d24ae3b 3 public:
DavidEGrayson 12:835a4d24ae3b 4
DavidEGrayson 12:835a4d24ae3b 5 Reckoner();
DavidEGrayson 12:835a4d24ae3b 6
DavidEGrayson 12:835a4d24ae3b 7 // Together, cos and sin form a vector with a magnitude close to 2^30 that indicates
DavidEGrayson 13:bba5b3abd13f 8 // the current position of the robot.
DavidEGrayson 12:835a4d24ae3b 9 // cos corresponds to the x component of the orientation vector.
DavidEGrayson 12:835a4d24ae3b 10 // sin corresponds to the y component of the orientation vector.
DavidEGrayson 12:835a4d24ae3b 11 int32_t cos, sin;
DavidEGrayson 12:835a4d24ae3b 12
DavidEGrayson 12:835a4d24ae3b 13 // Together, x and y are a vector that points from the starting point to the
DavidEGrayson 12:835a4d24ae3b 14 // robot's current position.
DavidEGrayson 13:bba5b3abd13f 15 // The untis are Df / (1<<14), where Df is the distance the robot moves forward
DavidEGrayson 13:bba5b3abd13f 16 // or backwards due to a single encoder tick.
DavidEGrayson 12:835a4d24ae3b 17 int32_t x, y;
DavidEGrayson 12:835a4d24ae3b 18
DavidEGrayson 12:835a4d24ae3b 19 void handleTickLeftForward();
DavidEGrayson 12:835a4d24ae3b 20 void handleTickLeftBackward();
DavidEGrayson 12:835a4d24ae3b 21 void handleTickRightForward();
DavidEGrayson 12:835a4d24ae3b 22 void handleTickRightBackward();
DavidEGrayson 12:835a4d24ae3b 23 void handleForward();
DavidEGrayson 12:835a4d24ae3b 24 void handleBackward();
DavidEGrayson 12:835a4d24ae3b 25 void handleRight();
DavidEGrayson 12:835a4d24ae3b 26 void handleLeft();
DavidEGrayson 12:835a4d24ae3b 27 };
DavidEGrayson 12:835a4d24ae3b 28
DavidEGrayson 12:835a4d24ae3b 29 extern Reckoner reckoner;