State machine code on the robot code
Dependencies: Motordriver mbed-rtos mbed
Fork of MultiModalRobot by
main.cpp@15:9bc36f47c8cf, 2017-11-20 (annotated)
- Committer:
- baijun
- Date:
- Mon Nov 20 03:18:42 2017 +0000
- Revision:
- 15:9bc36f47c8cf
- Parent:
- 14:f413a2b209b0
- Child:
- 16:47d3b1f2e90d
Same thing but with our new MultiModalRobot class.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
baijun | 14:f413a2b209b0 | 1 | //This will rotate the wheels so that after 5 seconds the robot counterclockwise and then clockwise |
emilmont | 1:491820ee784d | 2 | #include "mbed.h" |
mbed_official | 11:0309bef74ba8 | 3 | #include "rtos.h" |
baijun | 14:f413a2b209b0 | 4 | #include "motordriver.h" |
baijun | 15:9bc36f47c8cf | 5 | #include "MultiModalRobot.h" |
baijun | 14:f413a2b209b0 | 6 | |
baijun | 14:f413a2b209b0 | 7 | Motor lw(p26, p29, p30, 1); // pwm, fwd, rev LEFT WHEEL |
baijun | 14:f413a2b209b0 | 8 | Motor rw(p25, p28, p27, 1); // pwm, fwd, rev RIGHT WHEEL |
baijun | 15:9bc36f47c8cf | 9 | MultiModalRobot robot(lw, rw); |
emilmont | 1:491820ee784d | 10 | |
emilmont | 1:491820ee784d | 11 | int main() { |
baijun | 14:f413a2b209b0 | 12 | wait(5); |
baijun | 13:4c609396ed75 | 13 | for (float s= -1.0; s < 1.0 ; s += 0.01) { |
baijun | 15:9bc36f47c8cf | 14 | robot.driveWheels(s, -s); |
baijun | 13:4c609396ed75 | 15 | wait(0.02); |
emilmont | 1:491820ee784d | 16 | } |
baijun | 15:9bc36f47c8cf | 17 | robot.stop(0.5); |
baijun | 13:4c609396ed75 | 18 | } |