Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProfiledPIDController atGoal/atSetpoint will never return true #5040

Closed
Gregadeaux opened this issue Feb 2, 2023 · 1 comment
Closed

ProfiledPIDController atGoal/atSetpoint will never return true #5040

Gregadeaux opened this issue Feb 2, 2023 · 1 comment

Comments

@Gregadeaux
Copy link

Describe the bug
atGoal requires 2 things to return true

  1. The setpoint and goal equal each other
  2. atSetpoint to return true

atSetpoint requires 4 things to return true

  1. The Position error is within the Position Tolerance
  2. The Velocity Error is within the Velocity Tolerance
  3. The underlying PIDController property m_haveMeasurement is true
  4. The underlying PIDController property m_haveSetpoint is true

The only way for m_haveSetpoint to be true, is if setSetpoint is called on the underlying PIDController. But ProfiledPIDController only calls calculate, so m_haveSetpoint will never be true, thus ProfilePIDController.atGoal/atSetpoint() will never be true. PIDController needs to set m_haveSetpoint to true inside of the calculate function.

To Reproduce
Steps to reproduce the behavior:

  1. Create a ProfiledPIDController
  2. Call calculate
  3. Call atGoal or atSetpoint

Expected behavior
Should return true when the ProfiledPIDController has reached its goal

Desktop (please complete the following information):

  • WPILib Version: 2023.2.1
  • OS: OS X 13.1
  • Java version: 17
@calcmogul
Copy link
Member

The only way for m_haveSetpoint to be true, is if setSetpoint is called on the underlying PIDController.

This was fixed by #5021.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants