[wpimath] Fix PID atSetpoint to not return true prematurely (#4906)

Wait until setpoint and measurement have been set.
This commit is contained in:
sciencewhiz
2023-01-13 22:26:30 -08:00
committed by GitHub
parent e5a6197633
commit 1e05b21ab5
5 changed files with 21 additions and 11 deletions

View File

@@ -19,7 +19,7 @@ class PIDToleranceTest {
try (var controller = new PIDController(0.05, 0.0, 0.0)) {
controller.enableContinuousInput(-kRange / 2, kRange / 2);
assertTrue(controller.atSetpoint());
assertFalse(controller.atSetpoint());
}
}
@@ -28,10 +28,7 @@ class PIDToleranceTest {
try (var controller = new PIDController(0.05, 0.0, 0.0)) {
controller.enableContinuousInput(-kRange / 2, kRange / 2);
assertTrue(
controller.atSetpoint(),
"Error was not in tolerance when it should have been. Error was "
+ controller.getPositionError());
assertFalse(controller.atSetpoint());
controller.setTolerance(kTolerance);
controller.setSetpoint(kSetpoint);