3/26/16 12:25 am JJ

Dependents:   steppertest R5 2016 Robotics Team 1

Fork of scanner by David Vasquez

Committer:
j_j205
Date:
Sat Mar 26 22:59:50 2016 +0000
Revision:
11:c6152a32a104
Parent:
10:6a630acaeadb
made changes to driver and scanner 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 8:32a445ae1d72 5 #include "ShortRangeSensor.h"
Hellkite85 7:52c4be3bfc1b 6 #include "StepperDrive.h"
j_j205 0:999bb8fcd0b2 7
j_j205 0:999bb8fcd0b2 8 class Scanner
j_j205 0:999bb8fcd0b2 9 {
j_j205 2:b281034eda86 10 public:
Hellkite85 7:52c4be3bfc1b 11 Scanner(Serial &pc1, StepperDrive &_drive, PinName _servoL, PinName _servoR,
j_j205 8:32a445ae1d72 12 ShortRangeSensor &_shortRangeL, ShortRangeSensor &_shortRangeR,
j_j205 4:6a8d80954323 13 LongRangeSensor &_longRangeL, LongRangeSensor &_longRangeR,
j_j205 4:6a8d80954323 14 float _period = 0.2);
j_j205 3:992558a021d7 15 void huntMode();
Hellkite85 7:52c4be3bfc1b 16 void hunt();
j_j205 3:992558a021d7 17 void avoidMode();
j_j205 3:992558a021d7 18 void localize();
j_j205 6:5e24ff86b743 19 void localizeRight();
j_j205 6:5e24ff86b743 20 void localizeLeft();
j_j205 3:992558a021d7 21 float getDistLeft() {return distLeft;}
j_j205 3:992558a021d7 22 float getDistRight() {return distRight;}
j_j205 6:5e24ff86b743 23 float getDistForwardL() {return distForwardL;}
j_j205 6:5e24ff86b743 24 float getDistForwardR() {return distForwardR;}
j_j205 11:c6152a32a104 25 void setLocalizeRightFlag(bool value) {localizeRightFlag = value;}
j_j205 11:c6152a32a104 26 void setLocalizeLeftFlag(bool value) {localizeLeftFlag = value;}
j_j205 11:c6152a32a104 27 bool getYellowFlag() {return yellowFlag;}
j_j205 11:c6152a32a104 28 bool getObjectFound() {return objectFound;}
j_j205 11:c6152a32a104 29
j_j205 2:b281034eda86 30
j_j205 0:999bb8fcd0b2 31 private:
j_j205 11:c6152a32a104 32 static const int YELLOW = 1;
j_j205 11:c6152a32a104 33 static const int RED = 0;
j_j205 2:b281034eda86 34 static const int MIN_DUTY = 0;
j_j205 6:5e24ff86b743 35 static const int MAX_DUTY = 6;
j_j205 6:5e24ff86b743 36 static const int HALF_DUTY = 3;
j_j205 2:b281034eda86 37 static const float DELTA_DUTY = 4.2e-3;
j_j205 2:b281034eda86 38 float DUTY[13]; // {0.0500, 0.0542, 0.0583, 0.0625, 0.0667, 0.0708,
j_j205 2:b281034eda86 39 // 0.0750, 0.0792, 0.0833, 0.0875, 0.0917, 0.0958,
j_j205 2:b281034eda86 40 // 0.1000};
j_j205 2:b281034eda86 41 bool pitEnable;
j_j205 2:b281034eda86 42 int invertL;
j_j205 2:b281034eda86 43 int invertR;
j_j205 2:b281034eda86 44 int dutyL;
j_j205 2:b281034eda86 45 int dutyR;
j_j205 3:992558a021d7 46 float distLeft;
j_j205 3:992558a021d7 47 float distRight;
j_j205 6:5e24ff86b743 48 float distForwardL;
j_j205 6:5e24ff86b743 49 float distForwardR;
j_j205 0:999bb8fcd0b2 50 Serial &pc;
Hellkite85 7:52c4be3bfc1b 51 StepperDrive &drive;
j_j205 0:999bb8fcd0b2 52 PwmOut servoL;
j_j205 0:999bb8fcd0b2 53 PwmOut servoR;
j_j205 8:32a445ae1d72 54 ShortRangeSensor &shortRangeL;
j_j205 8:32a445ae1d72 55 ShortRangeSensor &shortRangeR;
j_j205 4:6a8d80954323 56 LongRangeSensor &longRangeL;
j_j205 4:6a8d80954323 57 LongRangeSensor &longRangeR;
j_j205 0:999bb8fcd0b2 58 float period;
j_j205 3:992558a021d7 59 bool obstacle;
j_j205 3:992558a021d7 60 bool huntFlag;
j_j205 6:5e24ff86b743 61 bool avoidFlag;
j_j205 6:5e24ff86b743 62 bool objectFound;
j_j205 10:6a630acaeadb 63 bool localizeRightFlag;
j_j205 10:6a630acaeadb 64 bool localizeLeftFlag;
j_j205 11:c6152a32a104 65 bool yellowFlag;
j_j205 2:b281034eda86 66
j_j205 3:992558a021d7 67 Ticker scanPit; // periodic interrupt timer
j_j205 2:b281034eda86 68
j_j205 2:b281034eda86 69 void scan();
j_j205 2:b281034eda86 70
j_j205 0:999bb8fcd0b2 71 };
j_j205 0:999bb8fcd0b2 72
j_j205 3:992558a021d7 73 #endif // SCANNER_H