3/26/16 12:25 am JJ

Dependents:   steppertest R5 2016 Robotics Team 1

Fork of scanner by David Vasquez

Committer:
Hellkite85
Date:
Sat Mar 26 23:01:49 2016 +0000
Revision:
9:bae63bc84829
Parent:
8:32a445ae1d72
Child:
12:514544a4014f
Modified hunt function in scanner.cpp and scanner.h on 3-26-2016

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"
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 2:b281034eda86 27
j_j205 0:999bb8fcd0b2 28 private:
j_j205 2:b281034eda86 29 static const int MIN_DUTY = 0;
j_j205 6:5e24ff86b743 30 static const int MAX_DUTY = 6;
j_j205 6:5e24ff86b743 31 static const int HALF_DUTY = 3;
j_j205 2:b281034eda86 32 static const float DELTA_DUTY = 4.2e-3;
j_j205 2:b281034eda86 33 float DUTY[13]; // {0.0500, 0.0542, 0.0583, 0.0625, 0.0667, 0.0708,
j_j205 2:b281034eda86 34 // 0.0750, 0.0792, 0.0833, 0.0875, 0.0917, 0.0958,
j_j205 2:b281034eda86 35 // 0.1000};
j_j205 2:b281034eda86 36 bool pitEnable;
j_j205 2:b281034eda86 37 int invertL;
j_j205 2:b281034eda86 38 int invertR;
j_j205 2:b281034eda86 39 int dutyL;
j_j205 2:b281034eda86 40 int dutyR;
j_j205 3:992558a021d7 41 float distLeft;
j_j205 3:992558a021d7 42 float distRight;
j_j205 6:5e24ff86b743 43 float distForwardL;
j_j205 6:5e24ff86b743 44 float distForwardR;
j_j205 0:999bb8fcd0b2 45 Serial &pc;
Hellkite85 7:52c4be3bfc1b 46 StepperDrive &drive;
j_j205 0:999bb8fcd0b2 47 PwmOut servoL;
j_j205 0:999bb8fcd0b2 48 PwmOut servoR;
j_j205 8:32a445ae1d72 49 ShortRangeSensor &shortRangeL;
j_j205 8:32a445ae1d72 50 ShortRangeSensor &shortRangeR;
j_j205 4:6a8d80954323 51 LongRangeSensor &longRangeL;
j_j205 4:6a8d80954323 52 LongRangeSensor &longRangeR;
j_j205 0:999bb8fcd0b2 53 float period;
j_j205 3:992558a021d7 54 bool obstacle;
j_j205 3:992558a021d7 55 bool huntFlag;
j_j205 6:5e24ff86b743 56 bool avoidFlag;
j_j205 6:5e24ff86b743 57 bool objectFound;
Hellkite85 9:bae63bc84829 58
Hellkite85 9:bae63bc84829 59 struct huntMove
Hellkite85 9:bae63bc84829 60 {
Hellkite85 9:bae63bc84829 61 float distance;
Hellkite85 9:bae63bc84829 62 float angle;
Hellkite85 9:bae63bc84829 63 };
j_j205 2:b281034eda86 64
j_j205 3:992558a021d7 65 Ticker scanPit; // periodic interrupt timer
j_j205 2:b281034eda86 66
j_j205 2:b281034eda86 67 void scan();
j_j205 2:b281034eda86 68
Hellkite85 9:bae63bc84829 69 std::stack<huntMove> myStack;
j_j205 0:999bb8fcd0b2 70 };
j_j205 0:999bb8fcd0b2 71
j_j205 3:992558a021d7 72 #endif // SCANNER_H