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.cpp@2:fc869e45e672, 2016-11-02 (annotated)
- Committer:
- ronvbree
- Date:
- Wed Nov 02 08:51:12 2016 +0000
- Revision:
- 2:fc869e45e672
- Parent:
- 0:494acf21d3bc
- Child:
- 7:a80cb6b06320
abcdg
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ronvbree | 0:494acf21d3bc | 1 | #include "controller.h" |
ronvbree | 0:494acf21d3bc | 2 | |
ronvbree | 0:494acf21d3bc | 3 | bool constantMovementTo(Arm arm, float length) { |
ronvbree | 0:494acf21d3bc | 4 | const float velocity = 2; |
ronvbree | 0:494acf21d3bc | 5 | float initialLength = arm.getLength(); |
ronvbree | 0:494acf21d3bc | 6 | float dLength = length-initialLength; |
ronvbree | 0:494acf21d3bc | 7 | |
ronvbree | 0:494acf21d3bc | 8 | if (dLength < 0) { |
ronvbree | 2:fc869e45e672 | 9 | arm.setVelocity(-1 * velocity); |
ronvbree | 0:494acf21d3bc | 10 | while (dLength < 0) { |
ronvbree | 0:494acf21d3bc | 11 | // Wait |
ronvbree | 0:494acf21d3bc | 12 | } |
ronvbree | 0:494acf21d3bc | 13 | arm.setVelocity(0); |
ronvbree | 0:494acf21d3bc | 14 | return true; |
ronvbree | 0:494acf21d3bc | 15 | } else { |
ronvbree | 0:494acf21d3bc | 16 | arm.setVelocity(velocity); |
ronvbree | 0:494acf21d3bc | 17 | while (dLength > 0) { |
ronvbree | 0:494acf21d3bc | 18 | // Wait |
ronvbree | 0:494acf21d3bc | 19 | } |
ronvbree | 0:494acf21d3bc | 20 | arm.setVelocity(0); |
ronvbree | 0:494acf21d3bc | 21 | return true; |
ronvbree | 0:494acf21d3bc | 22 | } |
ronvbree | 0:494acf21d3bc | 23 | } |
ronvbree | 0:494acf21d3bc | 24 | |
ronvbree | 0:494acf21d3bc | 25 | |
ronvbree | 0:494acf21d3bc | 26 | |
ronvbree | 0:494acf21d3bc | 27 | |
ronvbree | 0:494acf21d3bc | 28 | |
ronvbree | 0:494acf21d3bc | 29 |