a
Dependencies: Servo ServoArm mbed
Fork of PES_Official-TestF by
Headers/Robot.h@14:b61fbd13a7c9, 2017-05-10 (annotated)
- Committer:
- EpicG10
- Date:
- Wed May 10 19:53:08 2017 +0000
- Revision:
- 14:b61fbd13a7c9
- Parent:
- 11:292bdbd85a9c
- Child:
- 15:915f8839fe48
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
beacon | 0:d267b248eff4 | 1 | #ifndef ROBOT_H |
beacon | 0:d267b248eff4 | 2 | #define ROBOT_H |
beacon | 0:d267b248eff4 | 3 | |
beacon | 0:d267b248eff4 | 4 | #include <cstdlib> |
beacon | 0:d267b248eff4 | 5 | #include <mbed.h> |
beacon | 4:67d7177c213f | 6 | #include "Servo.h" |
beacon | 10:f76476943a6c | 7 | #include "ServoArm.h" |
beacon | 0:d267b248eff4 | 8 | |
beacon | 0:d267b248eff4 | 9 | #include "mbed.h" |
beacon | 0:d267b248eff4 | 10 | |
beacon | 0:d267b248eff4 | 11 | |
beacon | 0:d267b248eff4 | 12 | /* Declarations for the Motors in the Robot in order to drive -------- */ |
beacon | 1:388c915756f5 | 13 | |
beacon | 1:388c915756f5 | 14 | class DistanceSensors |
beacon | 1:388c915756f5 | 15 | { |
beacon | 1:388c915756f5 | 16 | public: |
beacon | 1:388c915756f5 | 17 | |
beacon | 4:67d7177c213f | 18 | DistanceSensors(AnalogIn* sensorVoltage, AnalogIn* frontS, AnalogIn* leftS, AnalogIn* rightS, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number); |
beacon | 1:388c915756f5 | 19 | DistanceSensors(); |
beacon | 1:388c915756f5 | 20 | |
beacon | 4:67d7177c213f | 21 | void init(AnalogIn* sensorVoltage, AnalogIn* frontS, AnalogIn* leftS, AnalogIn* rightS, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number); |
beacon | 1:388c915756f5 | 22 | virtual ~DistanceSensors(); |
beacon | 1:388c915756f5 | 23 | float read(); |
beacon | 1:388c915756f5 | 24 | |
beacon | 1:388c915756f5 | 25 | operator float(); //Is here to constantly return the value of read. |
beacon | 1:388c915756f5 | 26 | |
beacon | 1:388c915756f5 | 27 | private: |
beacon | 1:388c915756f5 | 28 | |
beacon | 1:388c915756f5 | 29 | AnalogIn* sensorVoltage; |
beacon | 4:67d7177c213f | 30 | AnalogIn* frontS; |
beacon | 4:67d7177c213f | 31 | AnalogIn* leftS; |
beacon | 4:67d7177c213f | 32 | AnalogIn* rightS; |
beacon | 4:67d7177c213f | 33 | |
beacon | 1:388c915756f5 | 34 | DigitalOut* bit0; |
beacon | 1:388c915756f5 | 35 | DigitalOut* bit1; |
beacon | 1:388c915756f5 | 36 | DigitalOut* bit2; |
beacon | 1:388c915756f5 | 37 | |
beacon | 1:388c915756f5 | 38 | int number; |
beacon | 1:388c915756f5 | 39 | |
beacon | 1:388c915756f5 | 40 | }; |
beacon | 1:388c915756f5 | 41 | |
beacon | 1:388c915756f5 | 42 | class Farbsensor |
beacon | 1:388c915756f5 | 43 | { |
beacon | 1:388c915756f5 | 44 | public: |
beacon | 1:388c915756f5 | 45 | |
beacon | 1:388c915756f5 | 46 | Farbsensor(); |
beacon | 1:388c915756f5 | 47 | Farbsensor(AnalogIn* FarbVoltage); |
beacon | 1:388c915756f5 | 48 | |
beacon | 1:388c915756f5 | 49 | void init(AnalogIn* FarbVoltage); |
beacon | 1:388c915756f5 | 50 | int read(); |
beacon | 1:388c915756f5 | 51 | operator int(); |
beacon | 1:388c915756f5 | 52 | |
beacon | 1:388c915756f5 | 53 | private: |
beacon | 1:388c915756f5 | 54 | |
beacon | 1:388c915756f5 | 55 | AnalogIn* FarbVoltage; |
beacon | 1:388c915756f5 | 56 | }; |
beacon | 6:ba26dd3251b3 | 57 | |
beacon | 4:67d7177c213f | 58 | class Arm{ |
beacon | 4:67d7177c213f | 59 | |
beacon | 4:67d7177c213f | 60 | public: |
beacon | 6:ba26dd3251b3 | 61 | |
beacon | 4:67d7177c213f | 62 | Arm(); |
beacon | 10:f76476943a6c | 63 | Arm(ServoArm* servoArm); |
beacon | 4:67d7177c213f | 64 | |
beacon | 10:f76476943a6c | 65 | void init(ServoArm* servoArm); |
beacon | 6:ba26dd3251b3 | 66 | |
beacon | 11:292bdbd85a9c | 67 | int collectToDown(); |
beacon | 11:292bdbd85a9c | 68 | int downToCollect(); |
beacon | 11:292bdbd85a9c | 69 | int collectToBack(); |
beacon | 11:292bdbd85a9c | 70 | int backToCollect(); |
beacon | 4:67d7177c213f | 71 | |
beacon | 4:67d7177c213f | 72 | private: |
beacon | 10:f76476943a6c | 73 | ServoArm* arm; |
beacon | 6:ba26dd3251b3 | 74 | float angle; |
beacon | 4:67d7177c213f | 75 | |
beacon | 4:67d7177c213f | 76 | }; |
beacon | 1:388c915756f5 | 77 | |
EpicG10 | 14:b61fbd13a7c9 | 78 | class Leiste{ |
EpicG10 | 14:b61fbd13a7c9 | 79 | |
EpicG10 | 14:b61fbd13a7c9 | 80 | public: |
EpicG10 | 14:b61fbd13a7c9 | 81 | |
EpicG10 | 14:b61fbd13a7c9 | 82 | Leiste(); |
EpicG10 | 14:b61fbd13a7c9 | 83 | Leiste(Servo* servoLeiste); |
EpicG10 | 14:b61fbd13a7c9 | 84 | |
EpicG10 | 14:b61fbd13a7c9 | 85 | void init(Servo* servoLeiste); |
EpicG10 | 14:b61fbd13a7c9 | 86 | |
EpicG10 | 14:b61fbd13a7c9 | 87 | int UpToDown(); |
EpicG10 | 14:b61fbd13a7c9 | 88 | int DownToUp(); |
EpicG10 | 14:b61fbd13a7c9 | 89 | |
EpicG10 | 14:b61fbd13a7c9 | 90 | |
EpicG10 | 14:b61fbd13a7c9 | 91 | private: |
EpicG10 | 14:b61fbd13a7c9 | 92 | Servo* leiste; |
EpicG10 | 14:b61fbd13a7c9 | 93 | |
EpicG10 | 14:b61fbd13a7c9 | 94 | |
EpicG10 | 14:b61fbd13a7c9 | 95 | }; |
EpicG10 | 14:b61fbd13a7c9 | 96 | |
beacon | 10:f76476943a6c | 97 | class Greifer |
beacon | 10:f76476943a6c | 98 | { |
beacon | 10:f76476943a6c | 99 | |
beacon | 10:f76476943a6c | 100 | public: |
beacon | 10:f76476943a6c | 101 | |
beacon | 10:f76476943a6c | 102 | Greifer(Servo* greifer); |
beacon | 10:f76476943a6c | 103 | Greifer(); |
beacon | 10:f76476943a6c | 104 | |
beacon | 10:f76476943a6c | 105 | void init(Servo* greifer); |
beacon | 11:292bdbd85a9c | 106 | int take(); |
beacon | 11:292bdbd85a9c | 107 | int leave(); |
beacon | 10:f76476943a6c | 108 | |
beacon | 10:f76476943a6c | 109 | private: |
beacon | 10:f76476943a6c | 110 | Servo* greifer; |
beacon | 10:f76476943a6c | 111 | |
beacon | 10:f76476943a6c | 112 | }; |
beacon | 10:f76476943a6c | 113 | |
beacon | 0:d267b248eff4 | 114 | class Robot |
beacon | 0:d267b248eff4 | 115 | { |
beacon | 0:d267b248eff4 | 116 | |
beacon | 0:d267b248eff4 | 117 | public: |
beacon | 0:d267b248eff4 | 118 | |
beacon | 0:d267b248eff4 | 119 | //Robot related: |
beacon | 10:f76476943a6c | 120 | Robot(PwmOut* left, PwmOut* right, DigitalOut* powerSignal, DigitalOut* leds, AnalogIn* FarbVoltage, AnalogIn* frontS, AnalogIn* leftS, AnalogIn* rightS, ServoArm* Arm, Servo* Greifer ); |
beacon | 4:67d7177c213f | 121 | |
beacon | 4:67d7177c213f | 122 | //Drive Functions |
beacon | 0:d267b248eff4 | 123 | void drive(); |
beacon | 4:67d7177c213f | 124 | void driveB(); |
beacon | 4:67d7177c213f | 125 | |
beacon | 0:d267b248eff4 | 126 | void turnLeft(); |
beacon | 4:67d7177c213f | 127 | void turnLeftS(); |
beacon | 0:d267b248eff4 | 128 | void turnRight(); |
beacon | 4:67d7177c213f | 129 | void turnRightS(); |
beacon | 0:d267b248eff4 | 130 | void turnAround(int left); |
beacon | 1:388c915756f5 | 131 | void stop(); |
beacon | 1:388c915756f5 | 132 | |
beacon | 4:67d7177c213f | 133 | //Functions that use the drive functions |
beacon | 4:67d7177c213f | 134 | void wallRight(int* counter, int* timer, int* lastAct); |
beacon | 4:67d7177c213f | 135 | void wallLeft(int* counter, int* timer, int* lastAct); |
beacon | 4:67d7177c213f | 136 | void wallFront(int* counter, int* timer, int* lastAct); |
beacon | 4:67d7177c213f | 137 | void counterMax(int* counter, int* timer, int* lastAct, int* rando); |
beacon | 4:67d7177c213f | 138 | |
beacon | 5:1aaf5de776ff | 139 | void legoFront(int* counter, int* timer, int* lastAct, int* legoFound, int* found); |
beacon | 4:67d7177c213f | 140 | void legoRight(int* counter, int* timer, int* lastAct, int* legoFound); |
beacon | 4:67d7177c213f | 141 | void legoLeft(int* counter, int* timer, int* lastAct, int* legoFound); |
beacon | 4:67d7177c213f | 142 | |
beacon | 4:67d7177c213f | 143 | void nothingFound(int* counter, int* timer, int* lastAct); |
beacon | 4:67d7177c213f | 144 | |
beacon | 11:292bdbd85a9c | 145 | int search(int* timer); |
beacon | 10:f76476943a6c | 146 | |
beacon | 10:f76476943a6c | 147 | int getErrorMotor(); |
beacon | 0:d267b248eff4 | 148 | |
beacon | 0:d267b248eff4 | 149 | //DistanceSensors related: |
beacon | 4:67d7177c213f | 150 | DistanceSensors sensors[9]; |
beacon | 4:67d7177c213f | 151 | AnalogIn* frontS; |
beacon | 4:67d7177c213f | 152 | AnalogIn* leftS; |
beacon | 4:67d7177c213f | 153 | AnalogIn* rightS; |
beacon | 4:67d7177c213f | 154 | |
beacon | 1:388c915756f5 | 155 | |
beacon | 1:388c915756f5 | 156 | void initializeDistanceSensors(); |
beacon | 1:388c915756f5 | 157 | //void init(); |
beacon | 0:d267b248eff4 | 158 | |
beacon | 1:388c915756f5 | 159 | //LEDS related: |
beacon | 6:ba26dd3251b3 | 160 | DigitalOut* leds; |
beacon | 0:d267b248eff4 | 161 | |
beacon | 1:388c915756f5 | 162 | //Farbsensors related: |
beacon | 6:ba26dd3251b3 | 163 | Farbsensor FarbVoltage; |
beacon | 6:ba26dd3251b3 | 164 | |
beacon | 6:ba26dd3251b3 | 165 | //Arm related: |
beacon | 6:ba26dd3251b3 | 166 | Arm Arm; |
beacon | 0:d267b248eff4 | 167 | |
beacon | 10:f76476943a6c | 168 | //Greifer related: |
beacon | 10:f76476943a6c | 169 | Greifer Greifer; |
beacon | 10:f76476943a6c | 170 | |
beacon | 0:d267b248eff4 | 171 | private: |
beacon | 0:d267b248eff4 | 172 | |
beacon | 0:d267b248eff4 | 173 | //Robot related: |
beacon | 0:d267b248eff4 | 174 | PwmOut* left; |
beacon | 0:d267b248eff4 | 175 | PwmOut* right; |
beacon | 10:f76476943a6c | 176 | DigitalIn* errorMotor; |
beacon | 0:d267b248eff4 | 177 | |
beacon | 0:d267b248eff4 | 178 | DigitalOut* powerSignal; |
beacon | 0:d267b248eff4 | 179 | DigitalIn* errorSignal; |
beacon | 0:d267b248eff4 | 180 | DigitalIn* overtemperatur; |
beacon | 0:d267b248eff4 | 181 | |
beacon | 10:f76476943a6c | 182 | Servo* greifer; |
beacon | 10:f76476943a6c | 183 | ServoArm* arm; |
beacon | 0:d267b248eff4 | 184 | }; |
beacon | 0:d267b248eff4 | 185 | |
beacon | 0:d267b248eff4 | 186 | #endif |