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 QEI biquadFilter
controller.h@7:a80cb6b06320, 2016-11-02 (annotated)
- Committer:
- ronvbree
- Date:
- Wed Nov 02 16:29:13 2016 +0000
- Revision:
- 7:a80cb6b06320
- Parent:
- 0:494acf21d3bc
- Child:
- 12:8295c02d740f
zyxvw
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ronvbree | 7:a80cb6b06320 | 1 | #include "robot.h" |
| ronvbree | 0:494acf21d3bc | 2 | |
| ronvbree | 7:a80cb6b06320 | 3 | class RobotController { |
| ronvbree | 7:a80cb6b06320 | 4 | private: |
| ronvbree | 7:a80cb6b06320 | 5 | // Robot |
| ronvbree | 7:a80cb6b06320 | 6 | Robot robot; |
| ronvbree | 7:a80cb6b06320 | 7 | // Serial communication for debugging purposes |
| ronvbree | 7:a80cb6b06320 | 8 | Serial debug; |
| ronvbree | 7:a80cb6b06320 | 9 | // Ticker |
| ronvbree | 7:a80cb6b06320 | 10 | Ticker ticker; |
| ronvbree | 7:a80cb6b06320 | 11 | // Controllers |
| ronvbree | 7:a80cb6b06320 | 12 | PIDController upperArmController; |
| ronvbree | 7:a80cb6b06320 | 13 | PIDController lowerArmController; |
| ronvbree | 7:a80cb6b06320 | 14 | // Reference arm lengths |
| ronvbree | 7:a80cb6b06320 | 15 | volatile float upperArmLengthReference; |
| ronvbree | 7:a80cb6b06320 | 16 | volatile float lowerArmLengthReference; |
| ronvbree | 7:a80cb6b06320 | 17 | |
| ronvbree | 7:a80cb6b06320 | 18 | // Control state flags |
| ronvbree | 7:a80cb6b06320 | 19 | volatile bool MOVE_BY_REFERENCE; |
| ronvbree | 7:a80cb6b06320 | 20 | volatile bool PAINT_MOVE_UP; |
| ronvbree | 7:a80cb6b06320 | 21 | volatile bool PAINT_MOVE_DOWN; |
| ronvbree | 7:a80cb6b06320 | 22 | |
| ronvbree | 7:a80cb6b06320 | 23 | void doTick(); |
| ronvbree | 7:a80cb6b06320 | 24 | |
| ronvbree | 7:a80cb6b06320 | 25 | public: |
| ronvbree | 7:a80cb6b06320 | 26 | // Constructor |
| ronvbree | 7:a80cb6b06320 | 27 | RobotController(); |
| ronvbree | 7:a80cb6b06320 | 28 | // Move the roller to a x,y coordinate |
| ronvbree | 7:a80cb6b06320 | 29 | void moveTo(float x, float y); |
| ronvbree | 7:a80cb6b06320 | 30 | // Move the arms to the indicates arm lengths |
| ronvbree | 7:a80cb6b06320 | 31 | void setArmLengths(float upper, float lower); |
| ronvbree | 7:a80cb6b06320 | 32 | // Move to max y |
| ronvbree | 7:a80cb6b06320 | 33 | void goToTop(); |
| ronvbree | 7:a80cb6b06320 | 34 | // Move to min y |
| ronvbree | 7:a80cb6b06320 | 35 | void goToBottom(); |
| ronvbree | 7:a80cb6b06320 | 36 | // Make a straight painting movement upwards |
| ronvbree | 7:a80cb6b06320 | 37 | void paintUp(); |
| ronvbree | 7:a80cb6b06320 | 38 | // Make a straight painting movement downwards |
| ronvbree | 7:a80cb6b06320 | 39 | void paintDown(); |
| ronvbree | 7:a80cb6b06320 | 40 | |
| ronvbree | 7:a80cb6b06320 | 41 | // Robot queries |
| ronvbree | 7:a80cb6b06320 | 42 | bool isKilled(); |
| ronvbree | 7:a80cb6b06320 | 43 | float getUpperArmLength(); |
| ronvbree | 7:a80cb6b06320 | 44 | float getLowerArmLength(); |
| ronvbree | 7:a80cb6b06320 | 45 | |
| ronvbree | 7:a80cb6b06320 | 46 | // Get the robot object |
| ronvbree | 7:a80cb6b06320 | 47 | Robot* getRobot(); |
| ronvbree | 7:a80cb6b06320 | 48 | |
| ronvbree | 7:a80cb6b06320 | 49 | }; |
| ronvbree | 0:494acf21d3bc | 50 | |
| ronvbree | 0:494acf21d3bc | 51 |