![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Code to run the microcontrollers on the R5 competition bot
Dependencies: LineSensors mbed
DriveController.h@22:8f726dc175cd, 2015-04-18 (annotated)
- Committer:
- Hypna
- Date:
- Sat Apr 18 04:57:20 2015 +0000
- Revision:
- 22:8f726dc175cd
- Parent:
- 18:2bd595af51d2
stuff
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Hypna | 0:e60f22c1d573 | 1 | #ifndef DRIVECONTROLLER_H |
Hypna | 0:e60f22c1d573 | 2 | #define DRIVECONTROLLER_H |
Hypna | 0:e60f22c1d573 | 3 | #include "mbed.h" |
Hypna | 5:f53f06a866e9 | 4 | #include "LineSensors.h" |
Hypna | 0:e60f22c1d573 | 5 | |
jmar11 | 16:b49db5c8e16c | 6 | typedef enum {NORTH, EAST, SOUTH, WEST} abs_direction; |
jmar11 | 16:b49db5c8e16c | 7 | //typedef enum {FORWARD, RIGHT, BACK, LEFT} rel_direction; |
jmar11 | 16:b49db5c8e16c | 8 | |
Hypna | 0:e60f22c1d573 | 9 | class DriveController |
Hypna | 0:e60f22c1d573 | 10 | { |
jmar11 | 16:b49db5c8e16c | 11 | public: |
jmar11 | 18:2bd595af51d2 | 12 | //private: |
jmar11 | 18:2bd595af51d2 | 13 | |
jmar11 | 16:b49db5c8e16c | 14 | typename ::abs_direction orient; |
jmar11 | 16:b49db5c8e16c | 15 | |
Hypna | 13:aa6f64c73271 | 16 | PwmOut treadSpeed1; |
Hypna | 13:aa6f64c73271 | 17 | PwmOut treadSpeed2; |
Hypna | 2:d0ce8e26cbc4 | 18 | |
Hypna | 13:aa6f64c73271 | 19 | DigitalOut treadDirection1; |
Hypna | 13:aa6f64c73271 | 20 | DigitalOut treadDirection2; |
Hypna | 4:ac6b2e5b240b | 21 | |
jmar11 | 18:2bd595af51d2 | 22 | LineSensors sensors; |
jmar11 | 18:2bd595af51d2 | 23 | |
Hypna | 5:f53f06a866e9 | 24 | bool sensorStates[8][3]; |
Hypna | 0:e60f22c1d573 | 25 | |
Hypna | 12:edcae0f36e9c | 26 | void spinTest(); |
Hypna | 12:edcae0f36e9c | 27 | double calculateError(); |
Hypna | 2:d0ce8e26cbc4 | 28 | bool intersection(); |
Hypna | 0:e60f22c1d573 | 29 | |
jmar11 | 18:2bd595af51d2 | 30 | //public: |
jmar11 | 18:2bd595af51d2 | 31 | |
Hypna | 2:d0ce8e26cbc4 | 32 | DriveController(); |
jmar11 | 17:5046b27f5441 | 33 | void move(typename ::abs_direction dir); |
jmar11 | 17:5046b27f5441 | 34 | void rotate(typename ::abs_direction dir); |
jmar11 | 18:2bd595af51d2 | 35 | typename ::abs_direction getOrient(); |
jmar11 | 18:2bd595af51d2 | 36 | void setSensors(); |
Hypna | 0:e60f22c1d573 | 37 | }; |
Hypna | 0:e60f22c1d573 | 38 | |
Hypna | 0:e60f22c1d573 | 39 | #endif |