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