BetterController: gain-schedule Kp against maxAlpha#2113
Open
Alex6511 wants to merge 1 commit intoMuMech:devfrom
Open
BetterController: gain-schedule Kp against maxAlpha#2113Alex6511 wants to merge 1 commit intoMuMech:devfrom
Alex6511 wants to merge 1 commit intoMuMech:devfrom
Conversation
Recent BetterController tuning (d65f0e9, 2025-12-02) raised the combined Kp_pos * Kp_vel product from ~8.5 to ~16.2, optimized against stock vessels with healthy gimbal authority. On RP-1 upper stages with weak vacuum-engine gimbals (maxAlpha ~0.3 rad/s^2), the velocity loop saturates on small tracking errors (>~0.02 rad), and combined with the ~60ms gimbal actuator lag this produces a structural limit cycle regardless of the cascade's bang-bang vs PID branch. Commit d65f0e9's message acknowledges the trade-off: "probably close to ideal performance without gain scheduling based on the gimbal response rate". This patch adds that scheduling. Formula (per axis, inside UpdatePredictionPI): kpScaleBase = Clamp(_maxAlpha[i] / KpScaleRef, KpScaleMin, 1.0) kpScale = sqrt(kpScaleBase) posKp_eff = (PosKp / warpFactor) * kpScale velKp_eff = VelKp * kpScale The sqrt distributes the combined-gain reduction equally across both PID loops, preserving the inner/outer cascade bandwidth separation ratio. At kpScaleBase = 0.25 (the new KpScaleMin default), each loop is scaled by 0.5, producing a combined-gain factor of 0.25 that matches a hand-tuned working configuration for Titan-class upper stages (Pos Kp=1.01, Vel Kp=4.0, roughly half of the current defaults). For strong-actuator stages where maxAlpha >= KpScaleRef, kpScale = 1.0 and the user's configured gains apply unmodified. New runtime-tunable fields (persistent, GUI-exposed alongside Soften): - KpScaleRef (default 1.0 rad/s^2): the maxAlpha value at which the user's configured gains apply unmodified. Below this, both loops scale down. - KpScaleMin (default 0.25): lower bound on kpScaleBase. Prevents pathological gain reduction on near-uncontrolled axes (roll with marginal control surface authority, etc). Flight-tested on RP-1 Titan-1-Agena-1: RMS attitude error in the upper stage burn drops from ~0.027 rad (sustained limit cycle) to ~0.00002 rad (noise floor) using the scheduler defaults, matching the hand-tuned reference configuration. Stage 6 (strong-gimbal sustainer) and stage 7 (booster) are unaffected by the scheduler within their normal maxAlpha range. The two new GUI text fields ("Kp Scale Ref", "Kp Scale Min") appear alongside the existing Soften tunable. SETTINGS_VERSION bumped 16 -> 17 so existing user configs pick up the new defaults via the OnModuleEnabled migration path.
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.
No description provided.