Remove percent tolerance from PID controller

It breaks the unit system badly; the tolerance member variable has
different units depending on percent vs absolute. Absolute tolerance is
a lot more natural than percent tolerance anyway.
This commit is contained in:
Tyler Veness
2019-08-25 13:01:51 -07:00
committed by Peter Johnson
parent 0ca8d667d2
commit ff8b8f0a8a
29 changed files with 121 additions and 507 deletions

View File

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

View File

@@ -117,8 +117,8 @@ public class PIDTest extends AbstractComsSetup {
me.reset();
}
private void setupAbsoluteTolerance() {
m_controller.setAbsoluteTolerance(absoluteTolerance);
private void setupTolerance() {
m_controller.setTolerance(absoluteTolerance);
}
private void setupOutputRange() {
@@ -127,7 +127,7 @@ public class PIDTest extends AbstractComsSetup {
@Test
public void testInitialSettings() {
setupAbsoluteTolerance();
setupTolerance();
setupOutputRange();
double reference = 2500.0;
m_controller.setSetpoint(reference);
@@ -143,7 +143,7 @@ public class PIDTest extends AbstractComsSetup {
@Test
public void testSetSetpoint() {
setupAbsoluteTolerance();
setupTolerance();
setupOutputRange();
double reference = 2500.0;
m_controller.setSetpoint(reference);
@@ -152,7 +152,7 @@ public class PIDTest extends AbstractComsSetup {
@Test(timeout = 10000)
public void testRotateToTarget() {
setupAbsoluteTolerance();
setupTolerance();
setupOutputRange();
double reference = 1000.0;
assertEquals(pidData() + "did not start at 0", 0, me.getMotor().get(), 0);