3/26/16 12:25 am JJ

Dependents:   steppertest R5 2016 Robotics Team 1

Fork of scanner by David Vasquez

Committer:
j_j205
Date:
Fri Apr 01 22:21:27 2016 +0000
Revision:
16:4e76b53cdef2
Parent:
14:d327852dafd1
stepper test 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"
Hellkite85 7:52c4be3bfc1b 5 #include "StepperDrive.h"
Hellkite85 9:bae63bc84829 6 #include <stack>
j_j205 0:999bb8fcd0b2 7
j_j205 0:999bb8fcd0b2 8 class Scanner
j_j205 0:999bb8fcd0b2 9 {
j_j205 2:b281034eda86 10 public:
j_j205 16:4e76b53cdef2 11 Scanner(Serial &pc1, StepperDrive &_drive, PinName _servoL, PinName _servoR,
j_j205 4:6a8d80954323 12 LongRangeSensor &_longRangeL, LongRangeSensor &_longRangeR,
j_j205 16:4e76b53cdef2 13 float _period = 0.2);
j_j205 3:992558a021d7 14 void huntMode();
Hellkite85 7:52c4be3bfc1b 15 void hunt();
j_j205 3:992558a021d7 16 void avoidMode();
j_j205 3:992558a021d7 17 void localize();
j_j205 6:5e24ff86b743 18 void localizeRight();
j_j205 6:5e24ff86b743 19 void localizeLeft();
j_j205 14:d327852dafd1 20 void localizeRightMode();
j_j205 14:d327852dafd1 21 void localizeLeftMode();
j_j205 3:992558a021d7 22 float getDistLeft() {return distLeft;}
j_j205 3:992558a021d7 23 float getDistRight() {return distRight;}
j_j205 6:5e24ff86b743 24 float getDistForwardL() {return distForwardL;}
j_j205 6:5e24ff86b743 25 float getDistForwardR() {return distForwardR;}
j_j205 12:514544a4014f 26 void setLocalizeRightFlag(bool value) {localizeRightFlag = value;}
j_j205 12:514544a4014f 27 void setLocalizeLeftFlag(bool value) {localizeLeftFlag = value;}
j_j205 12:514544a4014f 28 bool getYellowFlag() {return yellowFlag;}
j_j205 12:514544a4014f 29 bool getObjectFound() {return objectFound;}
j_j205 2:b281034eda86 30
j_j205 0:999bb8fcd0b2 31 private:
j_j205 12:514544a4014f 32 static const int YELLOW = 1;
j_j205 12:514544a4014f 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 4:6a8d80954323 54 LongRangeSensor &longRangeL;
j_j205 4:6a8d80954323 55 LongRangeSensor &longRangeR;
j_j205 0:999bb8fcd0b2 56 float period;
j_j205 3:992558a021d7 57 bool obstacle;
j_j205 3:992558a021d7 58 bool huntFlag;
j_j205 6:5e24ff86b743 59 bool avoidFlag;
j_j205 6:5e24ff86b743 60 bool objectFound;
j_j205 12:514544a4014f 61 bool localizeRightFlag;
j_j205 12:514544a4014f 62 bool localizeLeftFlag;
j_j205 12:514544a4014f 63 bool yellowFlag;
Hellkite85 9:bae63bc84829 64
Hellkite85 9:bae63bc84829 65 struct huntMove
Hellkite85 9:bae63bc84829 66 {
Hellkite85 9:bae63bc84829 67 float distance;
Hellkite85 9:bae63bc84829 68 float angle;
Hellkite85 9:bae63bc84829 69 };
j_j205 2:b281034eda86 70
j_j205 3:992558a021d7 71 Ticker scanPit; // periodic interrupt timer
j_j205 2:b281034eda86 72
j_j205 2:b281034eda86 73 void scan();
j_j205 2:b281034eda86 74
Hellkite85 9:bae63bc84829 75 std::stack<huntMove> myStack;
j_j205 0:999bb8fcd0b2 76 };
j_j205 0:999bb8fcd0b2 77
j_j205 3:992558a021d7 78 #endif // SCANNER_H