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
reckoner.h
00001 #pragma once 00002 00003 #define RECKONER_LOG_UNIT 14 00004 00005 class Reckoner 00006 { 00007 public: 00008 00009 Reckoner(); 00010 00011 // Together, cos and sin form a vector with a magnitude close to 2^14 that 00012 // indicate the current direction the robot is facint. 00013 int32_t cosv, sinv; 00014 00015 // Together, x and y are a vector that points from the starting point to the 00016 // robot's current position, with units of Df / (1<<14), where Df is the 00017 // distance the robot moves due to a single encoder tick. 00018 int32_t x, y; 00019 00020 void reset(); 00021 void handleForward(); 00022 void handleBackward(); 00023 void setTurnAngle(int32_t angle); 00024 };
Generated on Sun Jul 17 2022 15:45:15 by 1.7.2