3/26/16 12:25 am JJ
Dependents: steppertest R5 2016 Robotics Team 1
Fork of scanner by
scanner.h@10:6a630acaeadb, 2016-03-26 (annotated)
- Committer:
- j_j205
- Date:
- Sat Mar 26 16:51:33 2016 +0000
- Revision:
- 10:6a630acaeadb
- Parent:
- 8:32a445ae1d72
- Child:
- 11:c6152a32a104
for localizeRight and localizeLeft: added bools, and function calls in scan. JJ
Who changed what in which revision?
User | Revision | Line number | New 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 | 2:b281034eda86 | 25 | |
j_j205 | 0:999bb8fcd0b2 | 26 | private: |
j_j205 | 2:b281034eda86 | 27 | static const int MIN_DUTY = 0; |
j_j205 | 6:5e24ff86b743 | 28 | static const int MAX_DUTY = 6; |
j_j205 | 6:5e24ff86b743 | 29 | static const int HALF_DUTY = 3; |
j_j205 | 2:b281034eda86 | 30 | static const float DELTA_DUTY = 4.2e-3; |
j_j205 | 2:b281034eda86 | 31 | float DUTY[13]; // {0.0500, 0.0542, 0.0583, 0.0625, 0.0667, 0.0708, |
j_j205 | 2:b281034eda86 | 32 | // 0.0750, 0.0792, 0.0833, 0.0875, 0.0917, 0.0958, |
j_j205 | 2:b281034eda86 | 33 | // 0.1000}; |
j_j205 | 2:b281034eda86 | 34 | bool pitEnable; |
j_j205 | 2:b281034eda86 | 35 | int invertL; |
j_j205 | 2:b281034eda86 | 36 | int invertR; |
j_j205 | 2:b281034eda86 | 37 | int dutyL; |
j_j205 | 2:b281034eda86 | 38 | int dutyR; |
j_j205 | 3:992558a021d7 | 39 | float distLeft; |
j_j205 | 3:992558a021d7 | 40 | float distRight; |
j_j205 | 6:5e24ff86b743 | 41 | float distForwardL; |
j_j205 | 6:5e24ff86b743 | 42 | float distForwardR; |
j_j205 | 0:999bb8fcd0b2 | 43 | Serial &pc; |
Hellkite85 | 7:52c4be3bfc1b | 44 | StepperDrive &drive; |
j_j205 | 0:999bb8fcd0b2 | 45 | PwmOut servoL; |
j_j205 | 0:999bb8fcd0b2 | 46 | PwmOut servoR; |
j_j205 | 8:32a445ae1d72 | 47 | ShortRangeSensor &shortRangeL; |
j_j205 | 8:32a445ae1d72 | 48 | ShortRangeSensor &shortRangeR; |
j_j205 | 4:6a8d80954323 | 49 | LongRangeSensor &longRangeL; |
j_j205 | 4:6a8d80954323 | 50 | LongRangeSensor &longRangeR; |
j_j205 | 0:999bb8fcd0b2 | 51 | float period; |
j_j205 | 3:992558a021d7 | 52 | bool obstacle; |
j_j205 | 3:992558a021d7 | 53 | bool huntFlag; |
j_j205 | 6:5e24ff86b743 | 54 | bool avoidFlag; |
j_j205 | 6:5e24ff86b743 | 55 | bool objectFound; |
j_j205 | 10:6a630acaeadb | 56 | bool localizeRightFlag; |
j_j205 | 10:6a630acaeadb | 57 | bool localizeLeftFlag; |
j_j205 | 2:b281034eda86 | 58 | |
j_j205 | 3:992558a021d7 | 59 | Ticker scanPit; // periodic interrupt timer |
j_j205 | 2:b281034eda86 | 60 | |
j_j205 | 2:b281034eda86 | 61 | void scan(); |
j_j205 | 2:b281034eda86 | 62 | |
j_j205 | 0:999bb8fcd0b2 | 63 | }; |
j_j205 | 0:999bb8fcd0b2 | 64 | |
j_j205 | 3:992558a021d7 | 65 | #endif // SCANNER_H |