artf4127: Implemented velocity PID controller

Change-Id: I8c0f84422f7ca0ac5c50fddb282fb3452ee1d491
This commit is contained in:
Tyler Veness
2015-07-14 20:37:52 -07:00
parent f0e3bb5164
commit d5922bb037
43 changed files with 532 additions and 241 deletions

View File

@@ -167,7 +167,8 @@ public class MotorEncoderTest extends AbstractComsSetup {
@Test
public void testPIDController() {
public void testPositionPIDController() {
me.getEncoder().setPIDSourceType(PIDSourceType.kDisplacement);
PIDController pid = new PIDController(0.003, 0.001, 0, me.getEncoder(), me.getMotor());
pid.setAbsoluteTolerance(50);
pid.setOutputRange(-0.2, 0.2);
@@ -184,6 +185,24 @@ public class MotorEncoderTest extends AbstractComsSetup {
pid.free();
}
@Test
public void testVelocityPIDController() {
me.getEncoder().setPIDSourceType(PIDSourceType.kRate);
PIDController pid = new PIDController(0.002, 0, 0.0001, me.getEncoder(), me.getMotor());
pid.setAbsoluteTolerance(50);
pid.setOutputRange(-0.2, 0.2);
pid.setSetpoint(30);
pid.enable();
Timer.delay(10.0);
pid.disable();
assertTrue(
"PID loop did not reach setpoint within 10 seconds. The error was: " + pid.getError(),
pid.onTarget());
pid.free();
}
/**
* Checks to see if the encoders and counters are appropriately reset to zero