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
Diff: controller.cpp
- Revision:
- 0:494acf21d3bc
- Child:
- 2:fc869e45e672
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/controller.cpp Mon Oct 31 13:05:53 2016 +0000 @@ -0,0 +1,30 @@ +#include "controller.h" + +bool constantMovementTo(Arm arm, float length) { + const float velocity = 2; + float initialLength = arm.getLength(); + float dLength = length-initialLength; + + if (dLength < 0) { + velocity = -1 * velocity; + arm.setVelocity(velocity); + while (dLength < 0) { + // Wait + } + arm.setVelocity(0); + return true; + } else { + arm.setVelocity(velocity); + while (dLength > 0) { + // Wait + } + arm.setVelocity(0); + return true; + } +} + + + + + +