![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
These are the core files for the Robot at Team conception.
Brobot.h@11:05d5539141c8, 2017-06-01 (annotated)
- Committer:
- obrie829
- Date:
- Thu Jun 01 08:34:27 2017 +0000
- Revision:
- 11:05d5539141c8
- Parent:
- 8:351b0b7b05b2
- Child:
- 12:9a763d149f61
v10
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
obrie829 | 0:eba74e7a229b | 1 | /* |
obrie829 | 0:eba74e7a229b | 2 | * Brobot.h |
obrie829 | 0:eba74e7a229b | 3 | * |
obrie829 | 0:eba74e7a229b | 4 | */ |
obrie829 | 0:eba74e7a229b | 5 | |
obrie829 | 0:eba74e7a229b | 6 | #ifndef BROBOT_H_ |
obrie829 | 0:eba74e7a229b | 7 | #define BROBOT_H_ |
obrie829 | 0:eba74e7a229b | 8 | |
obrie829 | 0:eba74e7a229b | 9 | #include <cstdlib> |
obrie829 | 0:eba74e7a229b | 10 | #include <mbed.h> |
obrie829 | 8:351b0b7b05b2 | 11 | #include "SpeedControl.h" |
obrie829 | 11:05d5539141c8 | 12 | #include "PID_Control.h" |
obrie829 | 11:05d5539141c8 | 13 | #include "IRSensor.h" |
obrie829 | 11:05d5539141c8 | 14 | #include "Pixy.h" |
obrie829 | 0:eba74e7a229b | 15 | |
obrie829 | 0:eba74e7a229b | 16 | /** |
obrie829 | 0:eba74e7a229b | 17 | * This is a device driver class to drive the robot autonomously |
obrie829 | 0:eba74e7a229b | 18 | */ |
obrie829 | 0:eba74e7a229b | 19 | class Brobot |
obrie829 | 0:eba74e7a229b | 20 | { |
obrie829 | 0:eba74e7a229b | 21 | |
obrie829 | 0:eba74e7a229b | 22 | public: |
obrie829 | 0:eba74e7a229b | 23 | // constructors have same name as the class |
obrie829 | 11:05d5539141c8 | 24 | Brobot(SpeedControl& speedctrl, AnalogIn& distance, DigitalOut& enable, DigitalOut& bit0, DigitalOut& bit1, DigitalOut& bit2, DigitalOut* leds, Pixy& pixy); |
obrie829 | 0:eba74e7a229b | 25 | |
obrie829 | 11:05d5539141c8 | 26 | void avoidObstacleAndMove(int vtrans); |
obrie829 | 11:05d5539141c8 | 27 | void startLeds(); |
obrie829 | 11:05d5539141c8 | 28 | void ledShow(); |
obrie829 | 11:05d5539141c8 | 29 | void ledDistance(); |
obrie829 | 0:eba74e7a229b | 30 | void turnleft(); |
obrie829 | 0:eba74e7a229b | 31 | void turnright(); |
obrie829 | 0:eba74e7a229b | 32 | void forward(); |
obrie829 | 0:eba74e7a229b | 33 | void back(); |
obrie829 | 0:eba74e7a229b | 34 | void stop(); |
obrie829 | 11:05d5539141c8 | 35 | void rotate(int ammount); // |
obrie829 | 11:05d5539141c8 | 36 | void approachBrick(); |
obrie829 | 11:05d5539141c8 | 37 | void closeGrip(); |
obrie829 | 11:05d5539141c8 | 38 | void openGrip(); |
obrie829 | 11:05d5539141c8 | 39 | bool foundGreenBrick(); |
obrie829 | 11:05d5539141c8 | 40 | bool foundHome(); |
obrie829 | 0:eba74e7a229b | 41 | |
obrie829 | 11:05d5539141c8 | 42 | |
obrie829 | 0:eba74e7a229b | 43 | private: |
obrie829 | 11:05d5539141c8 | 44 | |
obrie829 | 11:05d5539141c8 | 45 | |
obrie829 | 11:05d5539141c8 | 46 | IRSensor sensor_front; // uses the default constructor because no arguments given |
obrie829 | 11:05d5539141c8 | 47 | IRSensor sensor_left; |
obrie829 | 11:05d5539141c8 | 48 | IRSensor sensor_right; |
obrie829 | 11:05d5539141c8 | 49 | DigitalOut* leds; //0 to 5 |
obrie829 | 11:05d5539141c8 | 50 | IRSensor sensors[6]; |
obrie829 | 11:05d5539141c8 | 51 | Ticker t1; |
obrie829 | 11:05d5539141c8 | 52 | PID_Control pid; |
obrie829 | 11:05d5539141c8 | 53 | PID_Control pixypid; |
obrie829 | 11:05d5539141c8 | 54 | Pixy pixy; |
obrie829 | 11:05d5539141c8 | 55 | SpeedControl& speedctrl; |
obrie829 | 11:05d5539141c8 | 56 | AnalogIn& distance; |
obrie829 | 11:05d5539141c8 | 57 | DigitalOut& enable; |
obrie829 | 11:05d5539141c8 | 58 | DigitalOut& bit0; |
obrie829 | 11:05d5539141c8 | 59 | DigitalOut& bit1; |
obrie829 | 11:05d5539141c8 | 60 | DigitalOut& bit2; |
obrie829 | 0:eba74e7a229b | 61 | }; |
obrie829 | 0:eba74e7a229b | 62 | |
obrie829 | 0:eba74e7a229b | 63 | #endif /* BROBOT_H_ */ |