Fix pid_tf coefficients for Ki=0 with first-order derivative filter#1058
Merged
Conversation
For Kp + Kd*s/(Tf*s+1) the numerator polynomial is ((Kp*Tf + Kd)*s + Kp), but the code was using [Kd*Tf + Kd, Kd] — Kp dropped entirely and replaced by Kd. The returned transfer function therefore did not contain the proportional term. The other branches in the same function (Ki!=0/filter_order=1 on the next line) use the correct form, which this brings into line. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This is an automated message.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1058 +/- ##
==========================================
+ Coverage 91.61% 91.64% +0.02%
==========================================
Files 42 42
Lines 5653 5659 +6
==========================================
+ Hits 5179 5186 +7
+ Misses 474 473 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Cross-check the transfer-function PID controller against the state-space realization, and against the analytical numerator [Kp*Tf+Kd, Kp]. On master both checks failed because the implementation emitted [Kd*Tf+Kd, Kd] (Kp dropped and replaced with Kd). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
For
pid_tfwithKi = 0, first-order derivative filter, and a non-nothingTf, the returned transfer function should bei.e. numerator
[Kp*Tf + Kd, Kp]. The code instead produced[Kd*Tf + Kd, Kd]—Kpwas dropped entirely and substituted withKd. The returned controller therefore contained no proportional term.The adjacent branch (
Ki != 0,filter_order == 1) uses the correct form[Kd + Kp*Tf, Ki*Tf + Kp, Ki]; collapsing that forKi = 0agrees with the fix.Test plan
pid_tf(Kp, 0, Kd; Tf, filter_order=1)against the analytical transfer function above (Kp=2, Kd=0.5, Tf=0.1).test_pid_design.jlstill pass.🤖 Generated with Claude Code