Project Paint / Mbed 2 deprecated arm_control

Dependencies:   mbed QEI biquadFilter

controller.cpp

Committer:
ronvbree
Date:
2016-11-02
Revision:
2:fc869e45e672
Parent:
0:494acf21d3bc
Child:
7:a80cb6b06320

File content as of revision 2:fc869e45e672:

#include "controller.h"

bool constantMovementTo(Arm arm, float length) {
    const float velocity = 2;
    float initialLength = arm.getLength();
    float dLength = length-initialLength;
    
    if (dLength < 0) {
        arm.setVelocity(-1 * velocity);
        while (dLength < 0) {
            // Wait
        }
        arm.setVelocity(0);
        return true;
    } else {
        arm.setVelocity(velocity);
        while (dLength > 0) {
            // Wait
        }
        arm.setVelocity(0);
        return true;
    }
}