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