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

Committer:
j_j205
Date:
Mon Mar 21 01:32:09 2016 +0000
Revision:
3:992558a021d7
Parent:
2:b281034eda86
Child:
4:6a8d80954323
3/20/16 updated code 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 0:999bb8fcd0b2 4 #include "Gp2x.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 0:999bb8fcd0b2 11 VL6180x &_shortRangeL, VL6180x &_shortRangeR, Gp2x &_longRangeL,
j_j205 2:b281034eda86 12 Gp2x &_longRangeR, float _period = 0.2);
j_j205 3:992558a021d7 13 void huntMode();
j_j205 3:992558a021d7 14 void avoidMode();
j_j205 3:992558a021d7 15 void localize();
j_j205 3:992558a021d7 16 float getDistLeft() {return distLeft;}
j_j205 3:992558a021d7 17 float getDistRight() {return distRight;}
j_j205 3:992558a021d7 18 float getDistForward() {return distForward;}
j_j205 2:b281034eda86 19
j_j205 0:999bb8fcd0b2 20 private:
j_j205 2:b281034eda86 21 static const int MIN_DUTY = 0;
j_j205 2:b281034eda86 22 static const int MAX_DUTY = 12;
j_j205 2:b281034eda86 23 static const int HALF_DUTY = 6;
j_j205 2:b281034eda86 24 static const float DELTA_DUTY = 4.2e-3;
j_j205 2:b281034eda86 25 float DUTY[13]; // {0.0500, 0.0542, 0.0583, 0.0625, 0.0667, 0.0708,
j_j205 2:b281034eda86 26 // 0.0750, 0.0792, 0.0833, 0.0875, 0.0917, 0.0958,
j_j205 2:b281034eda86 27 // 0.1000};
j_j205 2:b281034eda86 28 bool pitEnable;
j_j205 2:b281034eda86 29 int invertL;
j_j205 2:b281034eda86 30 int invertR;
j_j205 2:b281034eda86 31 int dutyL;
j_j205 2:b281034eda86 32 int dutyR;
j_j205 3:992558a021d7 33 float distLeft;
j_j205 3:992558a021d7 34 float distRight;
j_j205 3:992558a021d7 35 float distForward;
j_j205 0:999bb8fcd0b2 36 Serial &pc;
j_j205 0:999bb8fcd0b2 37 PwmOut servoL;
j_j205 0:999bb8fcd0b2 38 PwmOut servoR;
j_j205 0:999bb8fcd0b2 39 VL6180x &shortRangeL;
j_j205 0:999bb8fcd0b2 40 VL6180x &shortRangeR;
j_j205 0:999bb8fcd0b2 41 Gp2x &longRangeL;
j_j205 0:999bb8fcd0b2 42 Gp2x &longRangeR;
j_j205 0:999bb8fcd0b2 43 float period;
j_j205 3:992558a021d7 44 bool obstacle;
j_j205 3:992558a021d7 45 bool huntFlag;
j_j205 3:992558a021d7 46 bool avoidFlag;
j_j205 2:b281034eda86 47
j_j205 3:992558a021d7 48 Ticker scanPit; // periodic interrupt timer
j_j205 2:b281034eda86 49
j_j205 2:b281034eda86 50 void scan();
j_j205 2:b281034eda86 51
j_j205 0:999bb8fcd0b2 52 };
j_j205 0:999bb8fcd0b2 53
j_j205 3:992558a021d7 54 #endif // SCANNER_H