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

Committer:
j_j205
Date:
Fri Mar 25 19:51:11 2016 +0000
Revision:
6:5e24ff86b743
Parent:
4:6a8d80954323
3/25/16 2:50 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 6:5e24ff86b743 17 void localizeRight();
j_j205 6:5e24ff86b743 18 void localizeLeft();
j_j205 3:992558a021d7 19 float getDistLeft() {return distLeft;}
j_j205 3:992558a021d7 20 float getDistRight() {return distRight;}
j_j205 6:5e24ff86b743 21 float getDistForwardL() {return distForwardL;}
j_j205 6:5e24ff86b743 22 float getDistForwardR() {return distForwardR;}
j_j205 2:b281034eda86 23
j_j205 0:999bb8fcd0b2 24 private:
j_j205 2:b281034eda86 25 static const int MIN_DUTY = 0;
j_j205 6:5e24ff86b743 26 static const int MAX_DUTY = 6;
j_j205 6:5e24ff86b743 27 static const int HALF_DUTY = 3;
j_j205 2:b281034eda86 28 static const float DELTA_DUTY = 4.2e-3;
j_j205 2:b281034eda86 29 float DUTY[13]; // {0.0500, 0.0542, 0.0583, 0.0625, 0.0667, 0.0708,
j_j205 2:b281034eda86 30 // 0.0750, 0.0792, 0.0833, 0.0875, 0.0917, 0.0958,
j_j205 2:b281034eda86 31 // 0.1000};
j_j205 2:b281034eda86 32 bool pitEnable;
j_j205 2:b281034eda86 33 int invertL;
j_j205 2:b281034eda86 34 int invertR;
j_j205 2:b281034eda86 35 int dutyL;
j_j205 2:b281034eda86 36 int dutyR;
j_j205 3:992558a021d7 37 float distLeft;
j_j205 3:992558a021d7 38 float distRight;
j_j205 6:5e24ff86b743 39 float distForwardL;
j_j205 6:5e24ff86b743 40 float distForwardR;
j_j205 0:999bb8fcd0b2 41 Serial &pc;
j_j205 0:999bb8fcd0b2 42 PwmOut servoL;
j_j205 0:999bb8fcd0b2 43 PwmOut servoR;
j_j205 0:999bb8fcd0b2 44 VL6180x &shortRangeL;
j_j205 0:999bb8fcd0b2 45 VL6180x &shortRangeR;
j_j205 4:6a8d80954323 46 LongRangeSensor &longRangeL;
j_j205 4:6a8d80954323 47 LongRangeSensor &longRangeR;
j_j205 0:999bb8fcd0b2 48 float period;
j_j205 3:992558a021d7 49 bool obstacle;
j_j205 3:992558a021d7 50 bool huntFlag;
j_j205 6:5e24ff86b743 51 bool avoidFlag;
j_j205 6:5e24ff86b743 52 bool objectFound;
j_j205 2:b281034eda86 53
j_j205 3:992558a021d7 54 Ticker scanPit; // periodic interrupt timer
j_j205 2:b281034eda86 55
j_j205 2:b281034eda86 56 void scan();
j_j205 2:b281034eda86 57
j_j205 0:999bb8fcd0b2 58 };
j_j205 0:999bb8fcd0b2 59
j_j205 3:992558a021d7 60 #endif // SCANNER_H