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

Committer:
DavidEGrayson
Date:
Tue Aug 13 21:21:17 2019 +0000
Revision:
48:597738b77f77
Parent:
43:0e985a58f174
Changes from before the contest, I think.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DavidEGrayson 21:c279c6a83671 1 #pragma once
DavidEGrayson 21:c279c6a83671 2
DavidEGrayson 43:0e985a58f174 3 #define RECKONER_LOG_UNIT 14
DavidEGrayson 43:0e985a58f174 4
DavidEGrayson 12:835a4d24ae3b 5 class Reckoner
DavidEGrayson 12:835a4d24ae3b 6 {
DavidEGrayson 43:0e985a58f174 7 public:
DavidEGrayson 12:835a4d24ae3b 8
DavidEGrayson 12:835a4d24ae3b 9 Reckoner();
DavidEGrayson 12:835a4d24ae3b 10
DavidEGrayson 43:0e985a58f174 11 // Together, cos and sin form a vector with a magnitude close to 2^14 that
DavidEGrayson 43:0e985a58f174 12 // indicate the current direction the robot is facint.
DavidEGrayson 43:0e985a58f174 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 43:0e985a58f174 16 // robot's current position, with units of Df / (1<<14), where Df is the
DavidEGrayson 43:0e985a58f174 17 // distance the robot moves due to a single encoder tick.
DavidEGrayson 12:835a4d24ae3b 18 int32_t x, y;
DavidEGrayson 12:835a4d24ae3b 19
DavidEGrayson 21:c279c6a83671 20 void reset();
DavidEGrayson 12:835a4d24ae3b 21 void handleForward();
DavidEGrayson 12:835a4d24ae3b 22 void handleBackward();
DavidEGrayson 43:0e985a58f174 23 void setTurnAngle(int32_t angle);
DavidEGrayson 12:835a4d24ae3b 24 };