mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[commands] Fix ProfiledPIDSubsystem setGoal behavior (#4414)
Remove m_goal from ProfiledPIDSubsystem Delegate setGoal to backing controller
This commit is contained in:
@@ -41,7 +41,7 @@ class ProfiledPIDSubsystem : public SubsystemBase {
|
||||
|
||||
void Periodic() override {
|
||||
if (m_enabled) {
|
||||
UseOutput(m_controller.Calculate(GetMeasurement(), m_goal),
|
||||
UseOutput(m_controller.Calculate(GetMeasurement()),
|
||||
m_controller.GetSetpoint());
|
||||
}
|
||||
}
|
||||
@@ -51,14 +51,14 @@ class ProfiledPIDSubsystem : public SubsystemBase {
|
||||
*
|
||||
* @param goal The goal state for the subsystem's motion profile.
|
||||
*/
|
||||
void SetGoal(State goal) { m_goal = goal; }
|
||||
void SetGoal(State goal) { m_controller.SetGoal(goal); }
|
||||
|
||||
/**
|
||||
* Sets the goal state for the subsystem. Goal velocity assumed to be zero.
|
||||
*
|
||||
* @param goal The goal position for the subsystem's motion profile.
|
||||
*/
|
||||
void SetGoal(Distance_t goal) { m_goal = State{goal, Velocity_t(0)}; }
|
||||
void SetGoal(Distance_t goal) { SetGoal(State{goal, Velocity_t(0)}); }
|
||||
|
||||
/**
|
||||
* Enables the PID control. Resets the controller.
|
||||
@@ -110,8 +110,5 @@ class ProfiledPIDSubsystem : public SubsystemBase {
|
||||
* feedforward
|
||||
*/
|
||||
virtual void UseOutput(double output, State setpoint) = 0;
|
||||
|
||||
private:
|
||||
State m_goal;
|
||||
};
|
||||
} // namespace frc2
|
||||
|
||||
Reference in New Issue
Block a user