Project Paint / Mbed 2 deprecated arm_control

Dependencies:   mbed QEI biquadFilter

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?

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 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