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:
14:c8cca3687e64
Parent:
13:bba5b3abd13f
Child:
15:4df8c50b5e91
--- a/reckoner.cpp	Sun Feb 23 23:49:58 2014 +0000
+++ b/reckoner.cpp	Mon Feb 24 00:07:54 2014 +0000
@@ -81,6 +81,18 @@
 dA: Change in angle per encoder tick = Dw/W = 2*pi*35/(30*12) / 150 = 0.00439471394
 **/
 
+/** 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
+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).
+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
+
 #define DA 4718788  // 0.00439471394 * 0x40000000
 
 #define LOG_COS_TO_X_CONVERSION  16    // 30 - 14