David's line following code from the LVBots competition, 2015.
Dependencies: GeneralDebouncer Pacer PololuEncoder mbed
Fork of DeadReckoning by
Diff: reckoner.cpp
- 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