Scanner code will include the following: obstacle avoidance, hunting for victims, and localization checks.

scanner.h

Committer:
j_j205
Date:
2016-03-21
Revision:
3:992558a021d7
Parent:
2:b281034eda86
Child:
4:6a8d80954323

File content as of revision 3:992558a021d7:

#ifndef SCANNER_H
#define SCANNER_H
#include "mbed.h"
#include "Gp2x.h"
#include "VL6180x.h"

class Scanner
{
public:
    Scanner(Serial &pc1, PinName _servoL, PinName _servoR,
    VL6180x &_shortRangeL, VL6180x &_shortRangeR, Gp2x &_longRangeL,
    Gp2x &_longRangeR, float _period = 0.2);
    void huntMode();
    void avoidMode();
    void localize();
    float getDistLeft() {return distLeft;}
    float getDistRight() {return distRight;}
    float getDistForward() {return distForward;}

private:
    static const int MIN_DUTY = 0;
    static const int MAX_DUTY = 12;
    static const int HALF_DUTY = 6;
    static const float DELTA_DUTY = 4.2e-3;
    float DUTY[13]; // {0.0500, 0.0542, 0.0583, 0.0625, 0.0667, 0.0708,
                    // 0.0750, 0.0792, 0.0833, 0.0875, 0.0917, 0.0958,
                    // 0.1000};
    bool pitEnable;
    int invertL;
    int invertR;
    int dutyL;
    int dutyR;
    float distLeft;
    float distRight;
    float distForward;
    Serial &pc;
    PwmOut servoL;
    PwmOut servoR;
    VL6180x &shortRangeL;
    VL6180x &shortRangeR;
    Gp2x &longRangeL;
    Gp2x &longRangeR;
    float period;
    bool obstacle;
    bool huntFlag;
    bool avoidFlag;

    Ticker scanPit; // periodic interrupt timer

    void scan();

};

#endif // SCANNER_H