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
Diff: turn_sensor.cpp
- Revision:
- 47:9773dc14c834
- Parent:
- 42:96671b71aac5
- Child:
- 48:597738b77f77
--- a/turn_sensor.cpp Sun Jul 28 22:20:12 2019 +0000 +++ b/turn_sensor.cpp Wed Jul 31 07:14:09 2019 +0000 @@ -50,6 +50,17 @@ // (0.07 dps/digit) * (1/1000000 s/us) * (2^29/45 unit/degree) // = 14680064/17578125 unit/(digit*us) - angleUnsigned += (int64_t)d * 14680064 / 17578125; + if (rate > 0) + { + // Counter-clockwise scale factor calculated from log_190730_2.csv. + const double scale = 1.012394298; + angleUnsigned += (int64_t)d * (int32_t)(14680064 * scale) / 17578125; + } + else + { + // Clockwise scale factor calculated from log_190730_3.csv. + const double scale = 0.992376154; + angleUnsigned += (int64_t)d * (int32_t)(14680064 * scale) / 17578125; + } } } \ No newline at end of file