mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Clean up PIDController interface in preparation for ProfiledPIDController
This commit is contained in:
committed by
Peter Johnson
parent
fdc098267e
commit
fc98a79dbb
@@ -131,8 +131,8 @@ public class PIDTest extends AbstractComsSetup {
|
||||
setupOutputRange();
|
||||
double reference = 2500.0;
|
||||
m_controller.setSetpoint(reference);
|
||||
assertEquals("PID.getError() did not start at " + reference, reference, m_controller.getError(),
|
||||
0);
|
||||
assertEquals("PID.getPositionError() did not start at " + reference,
|
||||
reference, m_controller.getPositionError(), 0);
|
||||
m_builder.updateTable();
|
||||
assertEquals(k_p, m_table.getEntry("Kp").getDouble(9999999), 0);
|
||||
assertEquals(k_i, m_table.getEntry("Ki").getDouble(9999999), 0);
|
||||
@@ -155,17 +155,17 @@ public class PIDTest extends AbstractComsSetup {
|
||||
setupAbsoluteTolerance();
|
||||
setupOutputRange();
|
||||
double reference = 1000.0;
|
||||
assertEquals(pidData() + "did not start at 0", 0, m_controller.getOutput(), 0);
|
||||
assertEquals(pidData() + "did not start at 0", 0, me.getMotor().get(), 0);
|
||||
m_controller.setSetpoint(reference);
|
||||
assertEquals(pidData() + "did not have an error of " + reference, reference,
|
||||
m_controller.getError(), 0);
|
||||
m_controller.getPositionError(), 0);
|
||||
Notifier pidRunner = new Notifier(
|
||||
() -> me.getMotor().set(m_controller.calculate(me.getEncoder().getDistance())));
|
||||
pidRunner.startPeriodic(m_controller.getPeriod());
|
||||
Timer.delay(5);
|
||||
pidRunner.stop();
|
||||
assertTrue(pidData() + "Was not on Target. Controller Error: " + m_controller.getError(),
|
||||
m_controller.atSetpoint());
|
||||
assertTrue(pidData() + "Was not on Target. Controller Error: "
|
||||
+ m_controller.getPositionError(), m_controller.atSetpoint());
|
||||
}
|
||||
|
||||
private String pidData() {
|
||||
|
||||
Reference in New Issue
Block a user