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

Revision:
15:4df8c50b5e91
Parent:
14:c8cca3687e64
Child:
21:c279c6a83671
--- a/reckoner.cpp	Mon Feb 24 00:07:54 2014 +0000
+++ b/reckoner.cpp	Mon Feb 24 00:21:05 2014 +0000
@@ -84,16 +84,21 @@
 /** The theoretical value for dA above turned out to not be so accurate.
 After playing with the robot for a few minutes, the robot was confused about which direction
 it was facing by about 30 degrees.
-So I did an experiment to find out what dA really is.  I turned the robot around 15 times and
+So I did an experiment to find out what dA really is.  I turned the robot around many times and
 then took the difference in the encoder ticks from the left and right wheels.
-dA should be equal to 2*pi*numturns / (left_ticks - right_ticks).
+dA should be equal to 2*pi*(turn count) / (left_ticks - right_ticks).
 The experiment was performed several times to see how accurate the number is.
 
 (Theoretical dA                       = 0.00439471394 )
 Run 1: dA = 2*pi*15 / (11691 + 9414)  = 0.00446566119
 Run 2: dA = 2*pi*15 / (10232 + 10961) = 0.00444711836
+Run 3: dA = 2*pi*30 / (19823 + 22435) = 0.00446058874
+Run 4: dA = 2*pi*30 / (19794 + 22447) = 0.00446238392
 
-#define DA 4718788  // 0.00439471394 * 0x40000000
+The dA I decided to use is the average from runs 3 and 4:  dA = 0.00446148633
+**/
+
+#define DA 4790484  // 0.00446148633 * 0x40000000
 
 #define LOG_COS_TO_X_CONVERSION  16    // 30 - 14