[examples] Don't continually set setpoint in PotentiometerPID Examples (#3084)

This commit is contained in:
sciencewhiz
2021-01-13 20:09:08 -08:00
committed by GitHub
parent 8c5bfa0132
commit 04a90b5dd1
2 changed files with 7 additions and 3 deletions

View File

@@ -46,6 +46,7 @@ public class Robot extends TimedRobot {
m_joystick = new Joystick(kJoystickChannel);
m_pidController = new PIDController(kP, kI, kD);
m_pidController.setSetpoint(kSetPoints[m_index]);
}
@Override
@@ -60,9 +61,8 @@ public class Robot extends TimedRobot {
if (currentButtonValue && !m_previousButtonValue) {
// index of the elevator setpoint wraps around.
m_index = (m_index + 1) % kSetPoints.length;
m_pidController.setSetpoint(kSetPoints[m_index]);
}
m_previousButtonValue = currentButtonValue;
m_pidController.setSetpoint(kSetPoints[m_index]);
}
}