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 48:597738b77f77, committed 2019-08-13
- Comitter:
- DavidEGrayson
- Date:
- Tue Aug 13 21:21:17 2019 +0000
- Parent:
- 47:9773dc14c834
- Commit message:
- Changes from before the contest, I think.
Changed in this revision
diff -r 9773dc14c834 -r 597738b77f77 logger.h --- a/logger.h Wed Jul 31 07:14:09 2019 +0000 +++ b/logger.h Tue Aug 13 21:21:17 2019 +0000 @@ -2,7 +2,7 @@ #include <stdint.h> -#define LOGGER_SIZE 2000 +#define LOGGER_SIZE 3000 struct LogEntry {
diff -r 9773dc14c834 -r 597738b77f77 main.cpp --- a/main.cpp Wed Jul 31 07:14:09 2019 +0000 +++ b/main.cpp Tue Aug 13 21:21:17 2019 +0000 @@ -22,13 +22,14 @@ TurnSensor turnSensor; Logger logger; +const uint32_t timeout = 0; + +const uint32_t logSpacing = 200; + +const int16_t drivingSpeed = 500; + uint32_t totalEncoderCounts = 0; uint32_t nextLogEncoderCount = 0; -const uint32_t logSpacing = 250; - -const int16_t drivingSpeed = 400; - -const uint32_t timeout = 1*60000; void setLeds(bool v1, bool v2, bool v3, bool v4)
diff -r 9773dc14c834 -r 597738b77f77 turn_sensor.cpp --- a/turn_sensor.cpp Wed Jul 31 07:14:09 2019 +0000 +++ b/turn_sensor.cpp Tue Aug 13 21:21:17 2019 +0000 @@ -52,14 +52,16 @@ if (rate > 0) { - // Counter-clockwise scale factor calculated from log_190730_2.csv. - const double scale = 1.012394298; + // Counter-clockwise scale factors from + // log_190730_2.csv and log_190801_4.csv. + const double scale = 1.012394298 * 0.998207092; angleUnsigned += (int64_t)d * (int32_t)(14680064 * scale) / 17578125; } else { - // Clockwise scale factor calculated from log_190730_3.csv. - const double scale = 0.992376154; + // Clockwise scale factor calculated from + // log_190730_3.csv and then log_190801_3.csv. + const double scale = 0.992376154 * 0.999892525; angleUnsigned += (int64_t)d * (int32_t)(14680064 * scale) / 17578125; } }