Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Control/drivecontrol.h@0:cb667de3a336, 2017-05-06 (annotated)
- Committer:
- kolanery
- Date:
- Sat May 06 19:34:26 2017 +0000
- Revision:
- 0:cb667de3a336
- Child:
- 2:619b02232144
update baseline code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kolanery | 0:cb667de3a336 | 1 | #ifndef __DRIVE_CONTROL_H__ |
kolanery | 0:cb667de3a336 | 2 | #define __DRIVE_CONTROL_H__ |
kolanery | 0:cb667de3a336 | 3 | #include "motor.h" |
kolanery | 0:cb667de3a336 | 4 | |
kolanery | 0:cb667de3a336 | 5 | /** |
kolanery | 0:cb667de3a336 | 6 | * Control mouse movements. |
kolanery | 0:cb667de3a336 | 7 | * - PID Control based on sensor readings. |
kolanery | 0:cb667de3a336 | 8 | * - Output PWM signals to motors based on feedback loop. |
kolanery | 0:cb667de3a336 | 9 | * - Provides directional signals to the main control loop. |
kolanery | 0:cb667de3a336 | 10 | */ |
kolanery | 0:cb667de3a336 | 11 | class DriveControl { |
kolanery | 0:cb667de3a336 | 12 | |
kolanery | 0:cb667de3a336 | 13 | public: |
kolanery | 0:cb667de3a336 | 14 | int y; |
kolanery | 0:cb667de3a336 | 15 | int x; |
kolanery | 0:cb667de3a336 | 16 | DriveControl (int start_x, int start_y); |
kolanery | 0:cb667de3a336 | 17 | ~DriveControl(); |
kolanery | 0:cb667de3a336 | 18 | |
kolanery | 0:cb667de3a336 | 19 | int get_next_direction(); |
kolanery | 0:cb667de3a336 | 20 | |
kolanery | 0:cb667de3a336 | 21 | int get_next_state(int state); |
kolanery | 0:cb667de3a336 | 22 | |
kolanery | 0:cb667de3a336 | 23 | // Stops both motors. Assume no coasting. |
kolanery | 0:cb667de3a336 | 24 | void stop(); |
kolanery | 0:cb667de3a336 | 25 | |
kolanery | 0:cb667de3a336 | 26 | void drive_one_forward(); |
kolanery | 0:cb667de3a336 | 27 | |
kolanery | 0:cb667de3a336 | 28 | void turn(); |
kolanery | 0:cb667de3a336 | 29 | |
kolanery | 0:cb667de3a336 | 30 | void turn_left(); |
kolanery | 0:cb667de3a336 | 31 | |
kolanery | 0:cb667de3a336 | 32 | void turn_right(); |
kolanery | 0:cb667de3a336 | 33 | |
kolanery | 0:cb667de3a336 | 34 | bool has_front_wall(); |
kolanery | 0:cb667de3a336 | 35 | |
kolanery | 0:cb667de3a336 | 36 | bool has_right_wall(); |
kolanery | 0:cb667de3a336 | 37 | |
kolanery | 0:cb667de3a336 | 38 | bool has_left_wall(); |
kolanery | 0:cb667de3a336 | 39 | }; |
kolanery | 0:cb667de3a336 | 40 | #endif |