Skip to content

Add getters for Pid gains, timestep and output limits - #397

Merged
kmolan merged 1 commit into
kmolan:mainfrom
jay23606:pr-go/378-add-getters-for-the-gains-timestep-and-o
Dec 2, 2026
Merged

kmolan merged 1 commit into
kmolan:mainfrom
jay23606:pr-go/378-add-getters-for-the-gains-timestep-and-o

Conversation

@jay23606

@jay23606 jay23606 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Pid stores its three gains, its timestep and its output limits, but the only value a caller could read back was integral(). A caller could not log the gains in use or check them after set_gains.

Change

Adds five #[inline] #[must_use] getters to Pid:

  • proportional_gain(&self) -> T
  • integral_gain(&self) -> T, the gain, not the accumulated integral returned by integral()
  • derivative_gain(&self) -> T
  • timestep(&self) -> T
  • output_limits(&self) -> (T, T), returning (minimum, maximum)

Also adds a CHANGELOG line under Unreleased / Added.

Testing

  • cargo test -p multicalc getters_return_the_configured_values passes. The test checks the constructor values, the default unbounded limits, with_output_limits(-3.0, 4.0), and the three gains after set_gains(1.0, 0.2, 0.05).
  • cargo clippy -p multicalc --all-targets --features alloc -- -D warnings passes.

Regression test: untested: a small feature has no test that fails before the change

Fixes #378

@jay23606
jay23606 requested a review from kmolan as a code owner December 2, 2026 00:36
@kmolan
kmolan merged commit a9cf790 into kmolan:main Dec 2, 2026
16 checks passed
@jay23606
jay23606 deleted the pr-go/378-add-getters-for-the-gains-timestep-and-o branch December 3, 2026 01:16
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.

Add getters for the gains, timestep and output limits of Pid

2 participants