Project Paint / Mbed 2 deprecated arm_control

Dependencies:   mbed QEI biquadFilter

controller.cpp

Committer:
ronvbree
Date:
2016-10-31
Revision:
0:494acf21d3bc
Child:
2:fc869e45e672

File content as of revision 0:494acf21d3bc:

#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;
    }
}