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
line_tracker.h@24:fc01d9125d3b, 2014-02-28 (annotated)
- Committer:
- DavidEGrayson
- Date:
- Fri Feb 28 01:07:14 2014 +0000
- Revision:
- 24:fc01d9125d3b
- Parent:
- 22:44c032e59ff5
- Child:
- 46:df2c2d25c070
Fixed the problem with LineTracker always thinking the line was visible.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DavidEGrayson | 21:c279c6a83671 | 1 | #pragma once |
DavidEGrayson | 21:c279c6a83671 | 2 | |
DavidEGrayson | 21:c279c6a83671 | 3 | #include "line_sensors.h" |
DavidEGrayson | 21:c279c6a83671 | 4 | |
DavidEGrayson | 21:c279c6a83671 | 5 | class LineTracker |
DavidEGrayson | 21:c279c6a83671 | 6 | { |
DavidEGrayson | 21:c279c6a83671 | 7 | public: |
DavidEGrayson | 21:c279c6a83671 | 8 | LineTracker(); |
DavidEGrayson | 21:c279c6a83671 | 9 | |
DavidEGrayson | 21:c279c6a83671 | 10 | void updateCalibration(); |
DavidEGrayson | 21:c279c6a83671 | 11 | |
DavidEGrayson | 21:c279c6a83671 | 12 | void read(); |
DavidEGrayson | 21:c279c6a83671 | 13 | bool getLineVisible(); |
DavidEGrayson | 21:c279c6a83671 | 14 | uint16_t getLinePosition(); |
DavidEGrayson | 21:c279c6a83671 | 15 | |
DavidEGrayson | 21:c279c6a83671 | 16 | uint16_t rawValues[LINE_SENSOR_COUNT]; |
DavidEGrayson | 21:c279c6a83671 | 17 | uint16_t calibratedValues[LINE_SENSOR_COUNT]; |
DavidEGrayson | 21:c279c6a83671 | 18 | uint16_t calibratedMaximum[LINE_SENSOR_COUNT]; |
DavidEGrayson | 21:c279c6a83671 | 19 | uint16_t calibratedMinimum[LINE_SENSOR_COUNT]; |
DavidEGrayson | 21:c279c6a83671 | 20 | |
DavidEGrayson | 21:c279c6a83671 | 21 | private: |
DavidEGrayson | 21:c279c6a83671 | 22 | void readRawValues(); |
DavidEGrayson | 21:c279c6a83671 | 23 | void updateCalibratedValues(); |
DavidEGrayson | 21:c279c6a83671 | 24 | void updateLineStatus(); |
DavidEGrayson | 22:44c032e59ff5 | 25 | |
DavidEGrayson | 22:44c032e59ff5 | 26 | uint8_t calibrationState; |
DavidEGrayson | 22:44c032e59ff5 | 27 | uint16_t recentValuesMax[LINE_SENSOR_COUNT]; |
DavidEGrayson | 22:44c032e59ff5 | 28 | uint16_t recentValuesMin[LINE_SENSOR_COUNT]; |
DavidEGrayson | 21:c279c6a83671 | 29 | |
DavidEGrayson | 21:c279c6a83671 | 30 | bool lineVisible; |
DavidEGrayson | 21:c279c6a83671 | 31 | uint16_t linePosition; |
DavidEGrayson | 21:c279c6a83671 | 32 | }; |