Repository navigation
Conversation
A NaN or infinite temperature/sensor reading previously corrupted the integral term and produced a non-finite control output. Skip the update and return the last finite output when the measurement is non-finite so the controller can recover on the next good sample. Also treat None and bool as unusable inputs so they cannot be coerced into numeric measurements. Fixes m-lundberg#92.
Author
|
Closing this PR for now to free review bandwidth. Thanks for maintaining the project — happy to reopen or resubmit if this change is still useful later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A NaN or infinite process measurement could previously corrupt the integral term and produce a non-finite control output (e.g. a heater driven to full power after a bad temperature sample).
The controller now skips the update for non-finite inputs and returns the last output so it can recover on the next good sample.
Noneandboolare treated the same way so they cannot be coerced into numeric measurements.Changes
PID.__call__before error and I/D updatesNone,bool, first-call behavior, and recoveryTest plan
python -m pytest tests/test_pid.py::test_nan_input_does_not_poison_state tests/test_pid.py::test_nan_input_before_any_output_returns_none tests/test_pid.py::test_non_finite_variants_and_none_bool tests/test_pid.py::test_zero tests/test_pid.py::test_P tests/test_pid.py::test_output_limits -q(6 passed)Fixes #92.