a
Dependencies: Servo ServoArm mbed
Fork of PES_Official-TestF by
Headers/Robot.h@15:915f8839fe48, 2017-05-11 (annotated)
- Committer:
- EpicG10
- Date:
- Thu May 11 18:57:45 2017 +0000
- Revision:
- 15:915f8839fe48
- Parent:
- 14:b61fbd13a7c9
- Child:
- 16:f157e5ccd7d3
- Child:
- 17:4e1be70bdedb
c
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(); |
EpicG10 | 15:915f8839fe48 | 108 | void nullPos(); |
beacon | 10:f76476943a6c | 109 | |
beacon | 10:f76476943a6c | 110 | private: |
beacon | 10:f76476943a6c | 111 | Servo* greifer; |
beacon | 10:f76476943a6c | 112 | |
beacon | 10:f76476943a6c | 113 | }; |
beacon | 10:f76476943a6c | 114 | |
beacon | 0:d267b248eff4 | 115 | class Robot |
beacon | 0:d267b248eff4 | 116 | { |
beacon | 0:d267b248eff4 | 117 | |
beacon | 0:d267b248eff4 | 118 | public: |
beacon | 0:d267b248eff4 | 119 | |
beacon | 0:d267b248eff4 | 120 | //Robot related: |
EpicG10 | 15:915f8839fe48 | 121 | Robot(PwmOut* left, PwmOut* right, DigitalOut* powerSignal, DigitalOut* leds, AnalogIn* FarbVoltage, AnalogIn* frontS, AnalogIn* leftS, AnalogIn* rightS, ServoArm* Arm, Servo* Greifer, Servo* Leiste ); |
beacon | 4:67d7177c213f | 122 | |
beacon | 4:67d7177c213f | 123 | //Drive Functions |
beacon | 0:d267b248eff4 | 124 | void drive(); |
beacon | 4:67d7177c213f | 125 | void driveB(); |
beacon | 4:67d7177c213f | 126 | |
beacon | 0:d267b248eff4 | 127 | void turnLeft(); |
beacon | 4:67d7177c213f | 128 | void turnLeftS(); |
beacon | 0:d267b248eff4 | 129 | void turnRight(); |
beacon | 4:67d7177c213f | 130 | void turnRightS(); |
beacon | 0:d267b248eff4 | 131 | void turnAround(int left); |
beacon | 1:388c915756f5 | 132 | void stop(); |
beacon | 1:388c915756f5 | 133 | |
beacon | 4:67d7177c213f | 134 | //Functions that use the drive functions |
beacon | 4:67d7177c213f | 135 | void wallRight(int* counter, int* timer, int* lastAct); |
beacon | 4:67d7177c213f | 136 | void wallLeft(int* counter, int* timer, int* lastAct); |
beacon | 4:67d7177c213f | 137 | void wallFront(int* counter, int* timer, int* lastAct); |
beacon | 4:67d7177c213f | 138 | void counterMax(int* counter, int* timer, int* lastAct, int* rando); |
beacon | 4:67d7177c213f | 139 | |
beacon | 5:1aaf5de776ff | 140 | void legoFront(int* counter, int* timer, int* lastAct, int* legoFound, int* found); |
beacon | 4:67d7177c213f | 141 | void legoRight(int* counter, int* timer, int* lastAct, int* legoFound); |
beacon | 4:67d7177c213f | 142 | void legoLeft(int* counter, int* timer, int* lastAct, int* legoFound); |
beacon | 4:67d7177c213f | 143 | |
beacon | 4:67d7177c213f | 144 | void nothingFound(int* counter, int* timer, int* lastAct); |
beacon | 4:67d7177c213f | 145 | |
beacon | 11:292bdbd85a9c | 146 | int search(int* timer); |
beacon | 10:f76476943a6c | 147 | |
beacon | 10:f76476943a6c | 148 | int getErrorMotor(); |
beacon | 0:d267b248eff4 | 149 | |
beacon | 0:d267b248eff4 | 150 | //DistanceSensors related: |
beacon | 4:67d7177c213f | 151 | DistanceSensors sensors[9]; |
beacon | 4:67d7177c213f | 152 | AnalogIn* frontS; |
beacon | 4:67d7177c213f | 153 | AnalogIn* leftS; |
beacon | 4:67d7177c213f | 154 | AnalogIn* rightS; |
beacon | 4:67d7177c213f | 155 | |
beacon | 1:388c915756f5 | 156 | |
beacon | 1:388c915756f5 | 157 | void initializeDistanceSensors(); |
beacon | 1:388c915756f5 | 158 | //void init(); |
beacon | 0:d267b248eff4 | 159 | |
beacon | 1:388c915756f5 | 160 | //LEDS related: |
beacon | 6:ba26dd3251b3 | 161 | DigitalOut* leds; |
beacon | 0:d267b248eff4 | 162 | |
beacon | 1:388c915756f5 | 163 | //Farbsensors related: |
beacon | 6:ba26dd3251b3 | 164 | Farbsensor FarbVoltage; |
beacon | 6:ba26dd3251b3 | 165 | |
beacon | 6:ba26dd3251b3 | 166 | //Arm related: |
beacon | 6:ba26dd3251b3 | 167 | Arm Arm; |
beacon | 0:d267b248eff4 | 168 | |
beacon | 10:f76476943a6c | 169 | //Greifer related: |
beacon | 10:f76476943a6c | 170 | Greifer Greifer; |
beacon | 10:f76476943a6c | 171 | |
EpicG10 | 15:915f8839fe48 | 172 | //Leiste related: |
EpicG10 | 15:915f8839fe48 | 173 | Leiste Leiste; |
EpicG10 | 15:915f8839fe48 | 174 | |
beacon | 0:d267b248eff4 | 175 | private: |
beacon | 0:d267b248eff4 | 176 | |
beacon | 0:d267b248eff4 | 177 | //Robot related: |
beacon | 0:d267b248eff4 | 178 | PwmOut* left; |
beacon | 0:d267b248eff4 | 179 | PwmOut* right; |
beacon | 10:f76476943a6c | 180 | DigitalIn* errorMotor; |
beacon | 0:d267b248eff4 | 181 | |
beacon | 0:d267b248eff4 | 182 | DigitalOut* powerSignal; |
beacon | 0:d267b248eff4 | 183 | DigitalIn* errorSignal; |
beacon | 0:d267b248eff4 | 184 | DigitalIn* overtemperatur; |
beacon | 0:d267b248eff4 | 185 | |
beacon | 10:f76476943a6c | 186 | Servo* greifer; |
EpicG10 | 15:915f8839fe48 | 187 | Servo* leiste; |
beacon | 10:f76476943a6c | 188 | ServoArm* arm; |
beacon | 0:d267b248eff4 | 189 | }; |
beacon | 0:d267b248eff4 | 190 | |
beacon | 0:d267b248eff4 | 191 | #endif |