![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
vf
Dependencies: Servo ServoArm mbed
Fork of PES_Official by
Headers/Robot.h@3:fa61be4ecaa6, 2017-03-22 (annotated)
- Committer:
- beacon
- Date:
- Wed Mar 22 13:33:07 2017 +0000
- Revision:
- 3:fa61be4ecaa6
- Parent:
- 2:01e9de508316
- Child:
- 4:67d7177c213f
Official
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 | 0:d267b248eff4 | 6 | |
beacon | 0:d267b248eff4 | 7 | #include "mbed.h" |
beacon | 0:d267b248eff4 | 8 | |
beacon | 1:388c915756f5 | 9 | //DistanceSensors: |
beacon | 1:388c915756f5 | 10 | #define NEAR 0.1f //Used for distance Sensors. If they're to near to a wall -> turn |
beacon | 1:388c915756f5 | 11 | #define LEFT 5 //Arrayindex of the left Sensor & left LED |
beacon | 1:388c915756f5 | 12 | #define FWD 0 //Arrayindex of the front Sensor & front LED |
beacon | 1:388c915756f5 | 13 | #define RIGHT 1 //Arrayindex of the right Sensor & right LED. |
beacon | 1:388c915756f5 | 14 | |
beacon | 1:388c915756f5 | 15 | //ColorSensors: |
beacon | 1:388c915756f5 | 16 | #define RED_UPLIMIT 500 //Default limit in mV |
beacon | 1:388c915756f5 | 17 | #define GREEN_DOWNLIMIT 501 //Default limit in mV |
beacon | 1:388c915756f5 | 18 | #define GREEN_UPLIMIT 1200 //Default limit in mV |
beacon | 1:388c915756f5 | 19 | #define GREEN 1 |
beacon | 1:388c915756f5 | 20 | #define NOBLOCK 0 |
beacon | 1:388c915756f5 | 21 | #define RED -1 |
beacon | 1:388c915756f5 | 22 | |
beacon | 2:01e9de508316 | 23 | //Misc: |
beacon | 3:fa61be4ecaa6 | 24 | #define TIMEOUT 5 |
beacon | 2:01e9de508316 | 25 | |
beacon | 0:d267b248eff4 | 26 | |
beacon | 0:d267b248eff4 | 27 | /* Declarations for the Motors in the Robot in order to drive -------- */ |
beacon | 1:388c915756f5 | 28 | |
beacon | 1:388c915756f5 | 29 | class DistanceSensors |
beacon | 1:388c915756f5 | 30 | { |
beacon | 1:388c915756f5 | 31 | public: |
beacon | 1:388c915756f5 | 32 | |
beacon | 1:388c915756f5 | 33 | DistanceSensors(AnalogIn* sensorVoltage, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number); |
beacon | 1:388c915756f5 | 34 | DistanceSensors(); |
beacon | 1:388c915756f5 | 35 | |
beacon | 1:388c915756f5 | 36 | void init(AnalogIn* sensorVoltage, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number); |
beacon | 1:388c915756f5 | 37 | virtual ~DistanceSensors(); |
beacon | 1:388c915756f5 | 38 | float read(); |
beacon | 1:388c915756f5 | 39 | |
beacon | 1:388c915756f5 | 40 | operator float(); //Is here to constantly return the value of read. |
beacon | 1:388c915756f5 | 41 | |
beacon | 1:388c915756f5 | 42 | private: |
beacon | 1:388c915756f5 | 43 | |
beacon | 1:388c915756f5 | 44 | AnalogIn* sensorVoltage; |
beacon | 1:388c915756f5 | 45 | DigitalOut* bit0; |
beacon | 1:388c915756f5 | 46 | DigitalOut* bit1; |
beacon | 1:388c915756f5 | 47 | DigitalOut* bit2; |
beacon | 1:388c915756f5 | 48 | |
beacon | 1:388c915756f5 | 49 | int number; |
beacon | 1:388c915756f5 | 50 | |
beacon | 1:388c915756f5 | 51 | }; |
beacon | 1:388c915756f5 | 52 | |
beacon | 1:388c915756f5 | 53 | class Farbsensor |
beacon | 1:388c915756f5 | 54 | { |
beacon | 1:388c915756f5 | 55 | public: |
beacon | 1:388c915756f5 | 56 | |
beacon | 1:388c915756f5 | 57 | Farbsensor(); |
beacon | 1:388c915756f5 | 58 | Farbsensor(AnalogIn* FarbVoltage); |
beacon | 1:388c915756f5 | 59 | |
beacon | 1:388c915756f5 | 60 | void init(AnalogIn* FarbVoltage); |
beacon | 1:388c915756f5 | 61 | int read(); |
beacon | 1:388c915756f5 | 62 | operator int(); |
beacon | 1:388c915756f5 | 63 | |
beacon | 1:388c915756f5 | 64 | private: |
beacon | 1:388c915756f5 | 65 | |
beacon | 1:388c915756f5 | 66 | AnalogIn* FarbVoltage; |
beacon | 1:388c915756f5 | 67 | }; |
beacon | 1:388c915756f5 | 68 | |
beacon | 0:d267b248eff4 | 69 | class Robot |
beacon | 0:d267b248eff4 | 70 | { |
beacon | 0:d267b248eff4 | 71 | |
beacon | 0:d267b248eff4 | 72 | public: |
beacon | 0:d267b248eff4 | 73 | |
beacon | 0:d267b248eff4 | 74 | //Robot related: |
beacon | 1:388c915756f5 | 75 | Robot(PwmOut* left, PwmOut* right, DigitalOut* enableSignal, DigitalOut* leds, AnalogIn* FarbVoltage ); |
beacon | 0:d267b248eff4 | 76 | void drive(); |
beacon | 0:d267b248eff4 | 77 | void turnLeft(); |
beacon | 0:d267b248eff4 | 78 | void turnRight(); |
beacon | 0:d267b248eff4 | 79 | void turnAround(int left); |
beacon | 1:388c915756f5 | 80 | void stop(); |
beacon | 1:388c915756f5 | 81 | |
beacon | 2:01e9de508316 | 82 | void search(int* counter, Timer* t); |
beacon | 0:d267b248eff4 | 83 | |
beacon | 0:d267b248eff4 | 84 | //DistanceSensors related: |
beacon | 1:388c915756f5 | 85 | DistanceSensors sensors[6]; |
beacon | 1:388c915756f5 | 86 | |
beacon | 1:388c915756f5 | 87 | void initializeDistanceSensors(); |
beacon | 1:388c915756f5 | 88 | //void init(); |
beacon | 0:d267b248eff4 | 89 | |
beacon | 1:388c915756f5 | 90 | //LEDS related: |
beacon | 1:388c915756f5 | 91 | DigitalOut* leds; |
beacon | 0:d267b248eff4 | 92 | |
beacon | 1:388c915756f5 | 93 | //Farbsensors related: |
beacon | 1:388c915756f5 | 94 | Farbsensor FarbVoltage; |
beacon | 0:d267b248eff4 | 95 | |
beacon | 0:d267b248eff4 | 96 | private: |
beacon | 0:d267b248eff4 | 97 | |
beacon | 0:d267b248eff4 | 98 | //Robot related: |
beacon | 0:d267b248eff4 | 99 | PwmOut* left; |
beacon | 0:d267b248eff4 | 100 | PwmOut* right; |
beacon | 0:d267b248eff4 | 101 | |
beacon | 0:d267b248eff4 | 102 | DigitalOut* powerSignal; |
beacon | 0:d267b248eff4 | 103 | DigitalIn* errorSignal; |
beacon | 0:d267b248eff4 | 104 | DigitalIn* overtemperatur; |
beacon | 0:d267b248eff4 | 105 | |
beacon | 0:d267b248eff4 | 106 | |
beacon | 0:d267b248eff4 | 107 | }; |
beacon | 0:d267b248eff4 | 108 | |
beacon | 0:d267b248eff4 | 109 | #endif |