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

[wpimath] Fix PID atSetpoint to not return true prematurely #4906

Merged
merged 4 commits into from
Jan 14, 2023

Conversation

sciencewhiz
Copy link
Contributor

Wait until setpoint and measurement have been set
Fixes wpilibsuite/BetaTest#185

Wait until setpoint and measurement have been set
Fixes wpilibsuite/BetaTest#185
@sciencewhiz
Copy link
Contributor Author

@calcmogul I think see the problem you were worried about, if calculate is called before setSetpoint, this could still return the wrong value. But I think this decreases the likelihood that atSetpoint returns the wrong value and shouldn't really increase computation. What do you think?

@sciencewhiz
Copy link
Contributor Author

since both setPoint and calculate calculate the error, it actually doesn't matter which one is called first with regards to atSetpoint, as long as both are called.

@calcmogul
Copy link
Member

I think this is the best we can do without forcing the user to provide an initial setpoint and measurement in the constructor.

@sciencewhiz
Copy link
Contributor Author

I'll do C++ this afternoon

@sciencewhiz sciencewhiz marked this pull request as ready for review January 14, 2023 03:47
@sciencewhiz sciencewhiz requested a review from a team as a code owner January 14, 2023 03:47
@PeterJohnson PeterJohnson changed the title Fix PID atSetpoint to not return true prematurely [wpimath] Fix PID atSetpoint to not return true prematurely Jan 14, 2023
@PeterJohnson PeterJohnson merged commit 1e05b21 into wpilibsuite:main Jan 14, 2023
Starlight220 pushed a commit to Starlight220/allwpilib that referenced this pull request Mar 2, 2023
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

Successfully merging this pull request may close these issues.

3 participants