FRC1076 / 2019-Competition

Code for 2019 Competition
2 stars 1 forks source link

Create python code to drive a continously rotating servo #92

Open mcolinj opened 5 years ago

mcolinj commented 5 years ago

Ideally, we implement something like this except in python. (could do some more search for python code).

The servo requires different pulse widths for forward, neutral, reverse, so the interface should provide a set() method that takes (1, 0, -1) and then produces the appropriate pulse width using the PWM object.

You'll need to read a little about PWM and ask questions. We'll have a servo and robot for you to play with this.


/**
 * This is a driver for a continuous rotation servo with neutral at 1500us pulse
 * width.
 */

public class ContinuousRotationServo extends PWM {
    public ContinuousRotationServo(int channel) {
        super(channel);

        setBounds(1.0, 1.48, 1.5, 1.52, 2.0);
        enableDeadbandElimination(true);
    }

    @Override
    public void setBounds(double min, double dead_min, double center, double dead_max, double max) {
        super.setBounds(min, dead_min, center, dead_max, max);
    }

    public void set(double value) {
        setSpeed(value);
    }
}