mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Tuned test constants for VelocityPID.
Also added a GetAvgError method to the PIDController which averages the past n error values for use with noisy sensor values (namely, for the velocity stuff). Change-Id: I8a9cf40259dd56ef9093b36ed6891cc18b9131cf
This commit is contained in:
@@ -188,17 +188,19 @@ public class MotorEncoderTest extends AbstractComsSetup {
|
||||
@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);
|
||||
PIDController pid =
|
||||
new PIDController(1e-5, 0.0, 3e-5, 8e-5, me.getEncoder(), me.getMotor());
|
||||
pid.setAbsoluteTolerance(200);
|
||||
pid.setToleranceBuffer(50);
|
||||
pid.setOutputRange(-0.3, 0.3);
|
||||
pid.setSetpoint(2000);
|
||||
|
||||
pid.enable();
|
||||
Timer.delay(10.0);
|
||||
pid.disable();
|
||||
|
||||
assertTrue(
|
||||
"PID loop did not reach setpoint within 10 seconds. The error was: " + pid.getError(),
|
||||
"PID loop did not reach setpoint within 10 seconds. The error was: " + pid.getAvgError(),
|
||||
pid.onTarget());
|
||||
|
||||
pid.free();
|
||||
|
||||
Reference in New Issue
Block a user