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

Committer:
DavidEGrayson
Date:
16 months ago
Revision:
46:df2c2d25c070
Parent:
22:44c032e59ff5

File content as of revision 46:df2c2d25c070:

#pragma once

#include "line_sensors.h"

class LineTracker
{
    public:
    LineTracker();
    
    void updateCalibration();
    
    void read();    
    bool getLineVisible();
    uint16_t getLinePosition();
    
    uint16_t rawValues[LINE_SENSOR_COUNT];
    uint16_t calibratedMinimum[LINE_SENSOR_COUNT];
    uint16_t calibratedMaximum[LINE_SENSOR_COUNT];
    uint16_t calibratedValues[LINE_SENSOR_COUNT];
    
    private:
    void readRawValues();
    void updateCalibratedValues();
    void updateLineStatus();

    uint8_t calibrationState;
    uint16_t recentValuesMax[LINE_SENSOR_COUNT];
    uint16_t recentValuesMin[LINE_SENSOR_COUNT];
    
    bool lineVisible;
    uint16_t linePosition;
};