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

Dependencies:   GeneralDebouncer Pacer PololuEncoder mbed

Fork of DeadReckoning by David Grayson

Committer:
DavidEGrayson
Date:
Thu Apr 16 22:00:15 2015 +0000
Revision:
57:99bec7fab454
Parent:
46:f11cb4f93aac
Doubled the encoder counts for indicating the end of the course because we might have to start a little bit back from the finish line.

Who changed what in which revision?

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