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:
- 42:96671b71aac5
- Parent:
- 41:3ead1dd2cc3a
- Child:
- 47:9773dc14c834
--- a/turn_sensor.cpp Thu Jul 25 03:20:41 2019 +0000 +++ b/turn_sensor.cpp Sat Jul 27 20:58:46 2019 +0000 @@ -18,19 +18,12 @@ { if (l3gZAvailable() == 1) { - int32_t gz = l3gZRead(); + int32_t gz = l3gZReadCalibrated(); if (gz < -500000) { // error return; - } - - // The gyro zero rate on my robot, measured by testL3gAndCalibrate() on - // 2019-07-24 is about -6.5. So let's add 6 half the time and add 7 - // the other half of the time. This is a big hack. - static uint8_t updateCount = 0; - updateCount++; - gz = gz + 6 + (updateCount & 1); + } // The gyro on this robot is mounted upside down; account for that here so that // we can have counter-clockwise be a positive rotation.