mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[commands] Fix PIDSubsystem setSetpoint behavior (#4759)
No longer stores a temporary setpoint in PIDSubsystem, instead immediately sending to PIDController. This fixes an issue where the setpoint didn't take effect until the Subsystem Periodic method ran, and could cause commands to finish early if they were scheduled after the subsystem periodic method ran because it used the old setpoint.
This commit is contained in:
@@ -16,16 +16,16 @@ PIDSubsystem::PIDSubsystem(PIDController controller, double initialPosition)
|
||||
|
||||
void PIDSubsystem::Periodic() {
|
||||
if (m_enabled) {
|
||||
UseOutput(m_controller.Calculate(GetMeasurement(), m_setpoint), m_setpoint);
|
||||
UseOutput(m_controller.Calculate(GetMeasurement()), GetSetpoint());
|
||||
}
|
||||
}
|
||||
|
||||
void PIDSubsystem::SetSetpoint(double setpoint) {
|
||||
m_setpoint = setpoint;
|
||||
m_controller.SetSetpoint(setpoint);
|
||||
}
|
||||
|
||||
double PIDSubsystem::GetSetpoint() const {
|
||||
return m_setpoint;
|
||||
return m_controller.GetSetpoint();
|
||||
}
|
||||
|
||||
void PIDSubsystem::Enable() {
|
||||
|
||||
Reference in New Issue
Block a user