a
Dependencies: Servo ServoArm mbed
Fork of PES_Official-TestF by
Headers/Robot.h@9:ac362674c480, 2017-05-02 (annotated)
- Committer:
- beacon
- Date:
- Tue May 02 08:39:35 2017 +0000
- Revision:
- 9:ac362674c480
kl
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
beacon | 9:ac362674c480 | 1 | #ifndef ROBOT_H |
beacon | 9:ac362674c480 | 2 | #define ROBOT_H |
beacon | 9:ac362674c480 | 3 | |
beacon | 9:ac362674c480 | 4 | #include <cstdlib> |
beacon | 9:ac362674c480 | 5 | #include <mbed.h> |
beacon | 9:ac362674c480 | 6 | #include "Servo.h" |
beacon | 9:ac362674c480 | 7 | |
beacon | 9:ac362674c480 | 8 | #include "mbed.h" |
beacon | 9:ac362674c480 | 9 | |
beacon | 9:ac362674c480 | 10 | |
beacon | 9:ac362674c480 | 11 | /* Declarations for the Motors in the Robot in order to drive -------- */ |
beacon | 9:ac362674c480 | 12 | |
beacon | 9:ac362674c480 | 13 | class DistanceSensors |
beacon | 9:ac362674c480 | 14 | { |
beacon | 9:ac362674c480 | 15 | public: |
beacon | 9:ac362674c480 | 16 | |
beacon | 9:ac362674c480 | 17 | DistanceSensors(AnalogIn* sensorVoltage, AnalogIn* frontS, AnalogIn* leftS, AnalogIn* rightS, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number); |
beacon | 9:ac362674c480 | 18 | DistanceSensors(); |
beacon | 9:ac362674c480 | 19 | |
beacon | 9:ac362674c480 | 20 | void init(AnalogIn* sensorVoltage, AnalogIn* frontS, AnalogIn* leftS, AnalogIn* rightS, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number); |
beacon | 9:ac362674c480 | 21 | virtual ~DistanceSensors(); |
beacon | 9:ac362674c480 | 22 | float read(); |
beacon | 9:ac362674c480 | 23 | |
beacon | 9:ac362674c480 | 24 | operator float(); //Is here to constantly return the value of read. |
beacon | 9:ac362674c480 | 25 | |
beacon | 9:ac362674c480 | 26 | private: |
beacon | 9:ac362674c480 | 27 | |
beacon | 9:ac362674c480 | 28 | AnalogIn* sensorVoltage; |
beacon | 9:ac362674c480 | 29 | AnalogIn* frontS; |
beacon | 9:ac362674c480 | 30 | AnalogIn* leftS; |
beacon | 9:ac362674c480 | 31 | AnalogIn* rightS; |
beacon | 9:ac362674c480 | 32 | |
beacon | 9:ac362674c480 | 33 | DigitalOut* bit0; |
beacon | 9:ac362674c480 | 34 | DigitalOut* bit1; |
beacon | 9:ac362674c480 | 35 | DigitalOut* bit2; |
beacon | 9:ac362674c480 | 36 | |
beacon | 9:ac362674c480 | 37 | int number; |
beacon | 9:ac362674c480 | 38 | |
beacon | 9:ac362674c480 | 39 | }; |
beacon | 9:ac362674c480 | 40 | |
beacon | 9:ac362674c480 | 41 | class Farbsensor |
beacon | 9:ac362674c480 | 42 | { |
beacon | 9:ac362674c480 | 43 | public: |
beacon | 9:ac362674c480 | 44 | |
beacon | 9:ac362674c480 | 45 | Farbsensor(); |
beacon | 9:ac362674c480 | 46 | Farbsensor(AnalogIn* FarbVoltage); |
beacon | 9:ac362674c480 | 47 | |
beacon | 9:ac362674c480 | 48 | void init(AnalogIn* FarbVoltage); |
beacon | 9:ac362674c480 | 49 | int read(); |
beacon | 9:ac362674c480 | 50 | operator int(); |
beacon | 9:ac362674c480 | 51 | |
beacon | 9:ac362674c480 | 52 | private: |
beacon | 9:ac362674c480 | 53 | |
beacon | 9:ac362674c480 | 54 | AnalogIn* FarbVoltage; |
beacon | 9:ac362674c480 | 55 | }; |
beacon | 9:ac362674c480 | 56 | |
beacon | 9:ac362674c480 | 57 | class Arm{ |
beacon | 9:ac362674c480 | 58 | |
beacon | 9:ac362674c480 | 59 | public: |
beacon | 9:ac362674c480 | 60 | |
beacon | 9:ac362674c480 | 61 | Arm(); |
beacon | 9:ac362674c480 | 62 | Arm(Servo* servoArm); |
beacon | 9:ac362674c480 | 63 | |
beacon | 9:ac362674c480 | 64 | void init(Servo* servoArm); |
beacon | 9:ac362674c480 | 65 | |
beacon | 9:ac362674c480 | 66 | void collecttodown(int* done); |
beacon | 9:ac362674c480 | 67 | void downtocollect(int* done); |
beacon | 9:ac362674c480 | 68 | void collecttoback(int* done); |
beacon | 9:ac362674c480 | 69 | void backtocollect(int* done); |
beacon | 9:ac362674c480 | 70 | |
beacon | 9:ac362674c480 | 71 | private: |
beacon | 9:ac362674c480 | 72 | Servo* servoArm; |
beacon | 9:ac362674c480 | 73 | float angle; |
beacon | 9:ac362674c480 | 74 | |
beacon | 9:ac362674c480 | 75 | }; |
beacon | 9:ac362674c480 | 76 | |
beacon | 9:ac362674c480 | 77 | class Robot |
beacon | 9:ac362674c480 | 78 | { |
beacon | 9:ac362674c480 | 79 | |
beacon | 9:ac362674c480 | 80 | public: |
beacon | 9:ac362674c480 | 81 | |
beacon | 9:ac362674c480 | 82 | //Robot related: |
beacon | 9:ac362674c480 | 83 | Robot(PwmOut* left, PwmOut* right, DigitalOut* enableSignal, DigitalOut* leds, AnalogIn* FarbVoltage, AnalogIn* frontS, AnalogIn* leftS, AnalogIn* rightS, Servo* Arm ); |
beacon | 9:ac362674c480 | 84 | |
beacon | 9:ac362674c480 | 85 | //Drive Functions |
beacon | 9:ac362674c480 | 86 | void drive(); |
beacon | 9:ac362674c480 | 87 | void driveB(); |
beacon | 9:ac362674c480 | 88 | |
beacon | 9:ac362674c480 | 89 | void turnLeft(); |
beacon | 9:ac362674c480 | 90 | void turnLeftS(); |
beacon | 9:ac362674c480 | 91 | void turnRight(); |
beacon | 9:ac362674c480 | 92 | void turnRightS(); |
beacon | 9:ac362674c480 | 93 | void turnAround(int left); |
beacon | 9:ac362674c480 | 94 | void stop(); |
beacon | 9:ac362674c480 | 95 | |
beacon | 9:ac362674c480 | 96 | //Functions that use the drive functions |
beacon | 9:ac362674c480 | 97 | void wallRight(int* counter, int* timer, int* lastAct); |
beacon | 9:ac362674c480 | 98 | void wallLeft(int* counter, int* timer, int* lastAct); |
beacon | 9:ac362674c480 | 99 | void wallFront(int* counter, int* timer, int* lastAct); |
beacon | 9:ac362674c480 | 100 | void counterMax(int* counter, int* timer, int* lastAct, int* rando); |
beacon | 9:ac362674c480 | 101 | |
beacon | 9:ac362674c480 | 102 | void legoFront(int* counter, int* timer, int* lastAct, int* legoFound, int* found); |
beacon | 9:ac362674c480 | 103 | void legoRight(int* counter, int* timer, int* lastAct, int* legoFound); |
beacon | 9:ac362674c480 | 104 | void legoLeft(int* counter, int* timer, int* lastAct, int* legoFound); |
beacon | 9:ac362674c480 | 105 | |
beacon | 9:ac362674c480 | 106 | void nothingFound(int* counter, int* timer, int* lastAct); |
beacon | 9:ac362674c480 | 107 | |
beacon | 9:ac362674c480 | 108 | void search(int* counter, int* timer, int* found); |
beacon | 9:ac362674c480 | 109 | void lego(int* counter, Timer* t); |
beacon | 9:ac362674c480 | 110 | |
beacon | 9:ac362674c480 | 111 | //DistanceSensors related: |
beacon | 9:ac362674c480 | 112 | DistanceSensors sensors[9]; |
beacon | 9:ac362674c480 | 113 | AnalogIn* frontS; |
beacon | 9:ac362674c480 | 114 | AnalogIn* leftS; |
beacon | 9:ac362674c480 | 115 | AnalogIn* rightS; |
beacon | 9:ac362674c480 | 116 | |
beacon | 9:ac362674c480 | 117 | |
beacon | 9:ac362674c480 | 118 | void initializeDistanceSensors(); |
beacon | 9:ac362674c480 | 119 | //void init(); |
beacon | 9:ac362674c480 | 120 | |
beacon | 9:ac362674c480 | 121 | //LEDS related: |
beacon | 9:ac362674c480 | 122 | DigitalOut* leds; |
beacon | 9:ac362674c480 | 123 | |
beacon | 9:ac362674c480 | 124 | //Farbsensors related: |
beacon | 9:ac362674c480 | 125 | Farbsensor FarbVoltage; |
beacon | 9:ac362674c480 | 126 | |
beacon | 9:ac362674c480 | 127 | //Arm related: |
beacon | 9:ac362674c480 | 128 | Arm Arm; |
beacon | 9:ac362674c480 | 129 | |
beacon | 9:ac362674c480 | 130 | private: |
beacon | 9:ac362674c480 | 131 | |
beacon | 9:ac362674c480 | 132 | //Robot related: |
beacon | 9:ac362674c480 | 133 | PwmOut* left; |
beacon | 9:ac362674c480 | 134 | PwmOut* right; |
beacon | 9:ac362674c480 | 135 | |
beacon | 9:ac362674c480 | 136 | DigitalOut* powerSignal; |
beacon | 9:ac362674c480 | 137 | DigitalIn* errorSignal; |
beacon | 9:ac362674c480 | 138 | DigitalIn* overtemperatur; |
beacon | 9:ac362674c480 | 139 | |
beacon | 9:ac362674c480 | 140 | Servo* arm; |
beacon | 9:ac362674c480 | 141 | |
beacon | 9:ac362674c480 | 142 | |
beacon | 9:ac362674c480 | 143 | }; |
beacon | 9:ac362674c480 | 144 | |
beacon | 9:ac362674c480 | 145 | #endif |