![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
vf
Dependencies: Servo ServoArm mbed
Fork of PES_Official by
Headers/Robot.h@1:388c915756f5, 2017-03-19 (annotated)
- Committer:
- beacon
- Date:
- Sun Mar 19 12:20:26 2017 +0000
- Revision:
- 1:388c915756f5
- Parent:
- 0:d267b248eff4
- Child:
- 2:01e9de508316
[404 message not found]
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 | 0:d267b248eff4 | 23 | |
beacon | 0:d267b248eff4 | 24 | /* Declarations for the Motors in the Robot in order to drive -------- */ |
beacon | 1:388c915756f5 | 25 | |
beacon | 1:388c915756f5 | 26 | class DistanceSensors |
beacon | 1:388c915756f5 | 27 | { |
beacon | 1:388c915756f5 | 28 | public: |
beacon | 1:388c915756f5 | 29 | |
beacon | 1:388c915756f5 | 30 | DistanceSensors(AnalogIn* sensorVoltage, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number); |
beacon | 1:388c915756f5 | 31 | DistanceSensors(); |
beacon | 1:388c915756f5 | 32 | |
beacon | 1:388c915756f5 | 33 | void init(AnalogIn* sensorVoltage, DigitalOut* bit0, DigitalOut* bit1, DigitalOut* bit2, int number); |
beacon | 1:388c915756f5 | 34 | virtual ~DistanceSensors(); |
beacon | 1:388c915756f5 | 35 | float read(); |
beacon | 1:388c915756f5 | 36 | |
beacon | 1:388c915756f5 | 37 | operator float(); //Is here to constantly return the value of read. |
beacon | 1:388c915756f5 | 38 | |
beacon | 1:388c915756f5 | 39 | private: |
beacon | 1:388c915756f5 | 40 | |
beacon | 1:388c915756f5 | 41 | AnalogIn* sensorVoltage; |
beacon | 1:388c915756f5 | 42 | DigitalOut* bit0; |
beacon | 1:388c915756f5 | 43 | DigitalOut* bit1; |
beacon | 1:388c915756f5 | 44 | DigitalOut* bit2; |
beacon | 1:388c915756f5 | 45 | |
beacon | 1:388c915756f5 | 46 | int number; |
beacon | 1:388c915756f5 | 47 | |
beacon | 1:388c915756f5 | 48 | }; |
beacon | 1:388c915756f5 | 49 | |
beacon | 1:388c915756f5 | 50 | class Farbsensor |
beacon | 1:388c915756f5 | 51 | { |
beacon | 1:388c915756f5 | 52 | public: |
beacon | 1:388c915756f5 | 53 | |
beacon | 1:388c915756f5 | 54 | Farbsensor(); |
beacon | 1:388c915756f5 | 55 | Farbsensor(AnalogIn* FarbVoltage); |
beacon | 1:388c915756f5 | 56 | |
beacon | 1:388c915756f5 | 57 | void init(AnalogIn* FarbVoltage); |
beacon | 1:388c915756f5 | 58 | int read(); |
beacon | 1:388c915756f5 | 59 | operator int(); |
beacon | 1:388c915756f5 | 60 | |
beacon | 1:388c915756f5 | 61 | private: |
beacon | 1:388c915756f5 | 62 | |
beacon | 1:388c915756f5 | 63 | AnalogIn* FarbVoltage; |
beacon | 1:388c915756f5 | 64 | }; |
beacon | 1:388c915756f5 | 65 | |
beacon | 0:d267b248eff4 | 66 | class Robot |
beacon | 0:d267b248eff4 | 67 | { |
beacon | 0:d267b248eff4 | 68 | |
beacon | 0:d267b248eff4 | 69 | public: |
beacon | 0:d267b248eff4 | 70 | |
beacon | 0:d267b248eff4 | 71 | //Robot related: |
beacon | 1:388c915756f5 | 72 | Robot(PwmOut* left, PwmOut* right, DigitalOut* enableSignal, DigitalOut* leds, AnalogIn* FarbVoltage ); |
beacon | 0:d267b248eff4 | 73 | void drive(); |
beacon | 0:d267b248eff4 | 74 | void turnLeft(); |
beacon | 0:d267b248eff4 | 75 | void turnRight(); |
beacon | 0:d267b248eff4 | 76 | void turnAround(int left); |
beacon | 1:388c915756f5 | 77 | void stop(); |
beacon | 1:388c915756f5 | 78 | |
beacon | 1:388c915756f5 | 79 | void search(int* counter); |
beacon | 0:d267b248eff4 | 80 | |
beacon | 0:d267b248eff4 | 81 | //DistanceSensors related: |
beacon | 1:388c915756f5 | 82 | DistanceSensors sensors[6]; |
beacon | 1:388c915756f5 | 83 | |
beacon | 1:388c915756f5 | 84 | void initializeDistanceSensors(); |
beacon | 1:388c915756f5 | 85 | //void init(); |
beacon | 0:d267b248eff4 | 86 | |
beacon | 1:388c915756f5 | 87 | //LEDS related: |
beacon | 1:388c915756f5 | 88 | DigitalOut* leds; |
beacon | 0:d267b248eff4 | 89 | |
beacon | 1:388c915756f5 | 90 | //Farbsensors related: |
beacon | 1:388c915756f5 | 91 | Farbsensor FarbVoltage; |
beacon | 0:d267b248eff4 | 92 | |
beacon | 0:d267b248eff4 | 93 | private: |
beacon | 0:d267b248eff4 | 94 | |
beacon | 0:d267b248eff4 | 95 | //Robot related: |
beacon | 0:d267b248eff4 | 96 | PwmOut* left; |
beacon | 0:d267b248eff4 | 97 | PwmOut* right; |
beacon | 0:d267b248eff4 | 98 | |
beacon | 0:d267b248eff4 | 99 | DigitalOut* powerSignal; |
beacon | 0:d267b248eff4 | 100 | DigitalIn* errorSignal; |
beacon | 0:d267b248eff4 | 101 | DigitalIn* overtemperatur; |
beacon | 0:d267b248eff4 | 102 | |
beacon | 0:d267b248eff4 | 103 | |
beacon | 0:d267b248eff4 | 104 | }; |
beacon | 0:d267b248eff4 | 105 | |
beacon | 0:d267b248eff4 | 106 | #endif |