mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
[wpimath] Report error on negative PID gains (#6055)
Defaults PID gains to zero if any are invalid.
This commit is contained in:
@@ -21,8 +21,7 @@ public class Robot extends TimedRobot {
|
||||
static final double kHoldDistanceMillimeters = 1.0e3;
|
||||
|
||||
// proportional speed constant
|
||||
// negative because applying positive voltage will bring us closer to the target
|
||||
private static final double kP = -0.001;
|
||||
private static final double kP = 0.001;
|
||||
// integral speed constant
|
||||
private static final double kI = 0.0;
|
||||
// derivative speed constant
|
||||
|
||||
@@ -80,7 +80,7 @@ class UltrasonicPIDTest {
|
||||
m_driveSim.update(0.02);
|
||||
|
||||
double startingDistance = m_startToObject;
|
||||
double range = startingDistance - m_driveSim.getLeftPositionMeters();
|
||||
double range = m_driveSim.getLeftPositionMeters() - startingDistance;
|
||||
|
||||
m_ultrasonicSim.setRangeMeters(range);
|
||||
m_distanceMM = range * 1.0e3;
|
||||
@@ -126,10 +126,9 @@ class UltrasonicPIDTest {
|
||||
}
|
||||
|
||||
{
|
||||
// advance 100 timesteps
|
||||
SimHooks.stepTiming(2.0);
|
||||
SimHooks.stepTiming(5.0);
|
||||
|
||||
assertEquals(Robot.kHoldDistanceMillimeters, m_distanceMM, 10);
|
||||
assertEquals(Robot.kHoldDistanceMillimeters, m_distanceMM, 10.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user