Replace SetOutputRange() with SetIntegratorRange()

If users are attempting to use the output range to limit the controller
action, they should use ProfiledPIDController instead. If they actually
intended to clamp the output, they should use std::clamp().
This commit is contained in:
Tyler Veness
2019-08-26 21:40:30 -07:00
committed by Peter Johnson
parent ff8b8f0a8a
commit 9b6ffc201c
11 changed files with 55 additions and 72 deletions

View File

@@ -178,7 +178,7 @@ public class MotorEncoderTest extends AbstractComsSetup {
public void testPositionPIDController() {
PIDController pidController = new PIDController(0.001, 0.0005, 0);
pidController.setTolerance(50.0);
pidController.setOutputRange(-0.2, 0.2);
pidController.setIntegratorRange(-0.2, 0.2);
pidController.setSetpoint(1000);
Notifier pidRunner = new Notifier(
@@ -201,7 +201,6 @@ public class MotorEncoderTest extends AbstractComsSetup {
LinearFilter filter = LinearFilter.movingAverage(50);
PIDController pidController = new PIDController(1e-5, 0.0, 0.0006);
pidController.setTolerance(200);
pidController.setOutputRange(-0.3, 0.3);
pidController.setSetpoint(600);
Notifier pidRunner =

View File

@@ -45,7 +45,7 @@ public class PIDTest extends AbstractComsSetup {
private SendableBuilderImpl m_builder;
private static final double absoluteTolerance = 50;
private static final double outputRange = 0.25;
private static final double integratorRange = 0.25;
private PIDController m_controller = null;
private static MotorEncoderFixture<?> me = null;
@@ -121,14 +121,14 @@ public class PIDTest extends AbstractComsSetup {
m_controller.setTolerance(absoluteTolerance);
}
private void setupOutputRange() {
m_controller.setOutputRange(-outputRange, outputRange);
private void setupIntegratorRange() {
m_controller.setIntegratorRange(-integratorRange, integratorRange);
}
@Test
public void testInitialSettings() {
setupTolerance();
setupOutputRange();
setupIntegratorRange();
double reference = 2500.0;
m_controller.setSetpoint(reference);
assertEquals("PID.getPositionError() did not start at " + reference,
@@ -144,7 +144,7 @@ public class PIDTest extends AbstractComsSetup {
@Test
public void testSetSetpoint() {
setupTolerance();
setupOutputRange();
setupIntegratorRange();
double reference = 2500.0;
m_controller.setSetpoint(reference);
assertEquals("Did not correctly set reference", reference, m_controller.getSetpoint(), 1e-3);
@@ -153,7 +153,7 @@ public class PIDTest extends AbstractComsSetup {
@Test(timeout = 10000)
public void testRotateToTarget() {
setupTolerance();
setupOutputRange();
setupIntegratorRange();
double reference = 1000.0;
assertEquals(pidData() + "did not start at 0", 0, me.getMotor().get(), 0);
m_controller.setSetpoint(reference);
@@ -178,7 +178,7 @@ public class PIDTest extends AbstractComsSetup {
@Test(expected = RuntimeException.class)
public void testOnTargetNoToleranceSet() {
setupOutputRange();
setupIntegratorRange();
m_controller.atSetpoint();
}
}