3/26/16 12:25 am JJ

Dependents:   steppertest R5 2016 Robotics Team 1

Fork of scanner by David Vasquez

Committer:
j_j205
Date:
Tue Mar 22 03:00:16 2016 +0000
Revision:
4:6a8d80954323
Parent:
3:992558a021d7
Child:
6:5e24ff86b743
3/21/16 JJ

Who changed what in which revision?

UserRevisionLine numberNew contents of line
j_j205 0:999bb8fcd0b2 1 #ifndef SCANNER_H
j_j205 0:999bb8fcd0b2 2 #define SCANNER_H
j_j205 0:999bb8fcd0b2 3 #include "mbed.h"
j_j205 4:6a8d80954323 4 #include "LongRangeSensor.h"
j_j205 0:999bb8fcd0b2 5 #include "VL6180x.h"
j_j205 0:999bb8fcd0b2 6
j_j205 0:999bb8fcd0b2 7 class Scanner
j_j205 0:999bb8fcd0b2 8 {
j_j205 2:b281034eda86 9 public:
j_j205 2:b281034eda86 10 Scanner(Serial &pc1, PinName _servoL, PinName _servoR,
j_j205 4:6a8d80954323 11 VL6180x &_shortRangeL, VL6180x &_shortRangeR,
j_j205 4:6a8d80954323 12 LongRangeSensor &_longRangeL, LongRangeSensor &_longRangeR,
j_j205 4:6a8d80954323 13 float _period = 0.2);
j_j205 3:992558a021d7 14 void huntMode();
j_j205 3:992558a021d7 15 void avoidMode();
j_j205 3:992558a021d7 16 void localize();
j_j205 3:992558a021d7 17 float getDistLeft() {return distLeft;}
j_j205 3:992558a021d7 18 float getDistRight() {return distRight;}
j_j205 3:992558a021d7 19 float getDistForward() {return distForward;}
j_j205 2:b281034eda86 20
j_j205 0:999bb8fcd0b2 21 private:
j_j205 2:b281034eda86 22 static const int MIN_DUTY = 0;
j_j205 2:b281034eda86 23 static const int MAX_DUTY = 12;
j_j205 2:b281034eda86 24 static const int HALF_DUTY = 6;
j_j205 2:b281034eda86 25 static const float DELTA_DUTY = 4.2e-3;
j_j205 2:b281034eda86 26 float DUTY[13]; // {0.0500, 0.0542, 0.0583, 0.0625, 0.0667, 0.0708,
j_j205 2:b281034eda86 27 // 0.0750, 0.0792, 0.0833, 0.0875, 0.0917, 0.0958,
j_j205 2:b281034eda86 28 // 0.1000};
j_j205 2:b281034eda86 29 bool pitEnable;
j_j205 2:b281034eda86 30 int invertL;
j_j205 2:b281034eda86 31 int invertR;
j_j205 2:b281034eda86 32 int dutyL;
j_j205 2:b281034eda86 33 int dutyR;
j_j205 3:992558a021d7 34 float distLeft;
j_j205 3:992558a021d7 35 float distRight;
j_j205 3:992558a021d7 36 float distForward;
j_j205 0:999bb8fcd0b2 37 Serial &pc;
j_j205 0:999bb8fcd0b2 38 PwmOut servoL;
j_j205 0:999bb8fcd0b2 39 PwmOut servoR;
j_j205 0:999bb8fcd0b2 40 VL6180x &shortRangeL;
j_j205 0:999bb8fcd0b2 41 VL6180x &shortRangeR;
j_j205 4:6a8d80954323 42 LongRangeSensor &longRangeL;
j_j205 4:6a8d80954323 43 LongRangeSensor &longRangeR;
j_j205 0:999bb8fcd0b2 44 float period;
j_j205 3:992558a021d7 45 bool obstacle;
j_j205 3:992558a021d7 46 bool huntFlag;
j_j205 3:992558a021d7 47 bool avoidFlag;
j_j205 2:b281034eda86 48
j_j205 3:992558a021d7 49 Ticker scanPit; // periodic interrupt timer
j_j205 2:b281034eda86 50
j_j205 2:b281034eda86 51 void scan();
j_j205 2:b281034eda86 52
j_j205 0:999bb8fcd0b2 53 };
j_j205 0:999bb8fcd0b2 54
j_j205 3:992558a021d7 55 #endif // SCANNER_H