![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Code to run the microcontrollers on the R5 competition bot
Dependencies: LineSensors mbed
DriveController.h@9:01c17b286a99, 2014-10-24 (annotated)
- Committer:
- Hypna
- Date:
- Fri Oct 24 22:46:24 2014 +0000
- Revision:
- 9:01c17b286a99
- Parent:
- 5:f53f06a866e9
- Child:
- 10:210c8f1e3a92
Added log file for debugging
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 | 9:01c17b286a99 | 5 | #include <fstream> |
Hypna | 0:e60f22c1d573 | 6 | |
Hypna | 0:e60f22c1d573 | 7 | class DriveController |
Hypna | 0:e60f22c1d573 | 8 | { |
Hypna | 0:e60f22c1d573 | 9 | private: |
Hypna | 9:01c17b286a99 | 10 | ofstream debugLog; |
Hypna | 9:01c17b286a99 | 11 | |
Hypna | 4:ac6b2e5b240b | 12 | PwmOut wheelSpeed1; |
Hypna | 4:ac6b2e5b240b | 13 | PwmOut wheelSpeed2; |
Hypna | 4:ac6b2e5b240b | 14 | PwmOut wheelSpeed3; |
Hypna | 4:ac6b2e5b240b | 15 | PwmOut wheelSpeed4; |
Hypna | 2:d0ce8e26cbc4 | 16 | |
Hypna | 4:ac6b2e5b240b | 17 | DigitalOut wheelDirection1; |
Hypna | 4:ac6b2e5b240b | 18 | DigitalOut wheelDirection2; |
Hypna | 4:ac6b2e5b240b | 19 | DigitalOut wheelDirection3; |
Hypna | 4:ac6b2e5b240b | 20 | DigitalOut wheelDirection4; |
Hypna | 4:ac6b2e5b240b | 21 | |
Hypna | 5:f53f06a866e9 | 22 | I2CSlave i2c; |
Hypna | 4:ac6b2e5b240b | 23 | |
Hypna | 5:f53f06a866e9 | 24 | LineSensors sensors; |
Hypna | 5:f53f06a866e9 | 25 | bool sensorStates[8][3]; |
Hypna | 0:e60f22c1d573 | 26 | |
Hypna | 5:f53f06a866e9 | 27 | int command; |
Hypna | 5:f53f06a866e9 | 28 | int edge; |
Hypna | 0:e60f22c1d573 | 29 | |
Hypna | 5:f53f06a866e9 | 30 | void move(char direction = 'F'); |
Hypna | 2:d0ce8e26cbc4 | 31 | void getCommand(); |
Hypna | 5:f53f06a866e9 | 32 | void rotate(char direction); |
Hypna | 4:ac6b2e5b240b | 33 | void sendComplete(); |
Hypna | 5:f53f06a866e9 | 34 | int calculateError(); |
Hypna | 2:d0ce8e26cbc4 | 35 | bool intersection(); |
Hypna | 0:e60f22c1d573 | 36 | |
Hypna | 0:e60f22c1d573 | 37 | public: |
Hypna | 2:d0ce8e26cbc4 | 38 | DriveController(); |
Hypna | 0:e60f22c1d573 | 39 | void go(); |
Hypna | 0:e60f22c1d573 | 40 | }; |
Hypna | 0:e60f22c1d573 | 41 | |
Hypna | 0:e60f22c1d573 | 42 | #endif |