Project Paint / Mbed 2 deprecated arm_control

Dependencies:   mbed QEI biquadFilter

Committer:
ronvbree
Date:
Mon Oct 31 13:05:53 2016 +0000
Revision:
0:494acf21d3bc
Child:
2:fc869e45e672
test

Who changed what in which revision?

UserRevisionLine numberNew 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 0:494acf21d3bc 9 velocity = -1 * velocity;
ronvbree 0:494acf21d3bc 10 arm.setVelocity(velocity);
ronvbree 0:494acf21d3bc 11 while (dLength < 0) {
ronvbree 0:494acf21d3bc 12 // Wait
ronvbree 0:494acf21d3bc 13 }
ronvbree 0:494acf21d3bc 14 arm.setVelocity(0);
ronvbree 0:494acf21d3bc 15 return true;
ronvbree 0:494acf21d3bc 16 } else {
ronvbree 0:494acf21d3bc 17 arm.setVelocity(velocity);
ronvbree 0:494acf21d3bc 18 while (dLength > 0) {
ronvbree 0:494acf21d3bc 19 // Wait
ronvbree 0:494acf21d3bc 20 }
ronvbree 0:494acf21d3bc 21 arm.setVelocity(0);
ronvbree 0:494acf21d3bc 22 return true;
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
ronvbree 0:494acf21d3bc 30