Fix inverted tpa_pitch_compensation documentation and comment - #11956
sensei-hacker wants to merge 1 commit into
Conversation
The description and inline comment for tpa_pitch_compensation stated "increase throttle when pitching up" - but the code and its own math (groundCos positive while diving) actually raise the virtual TPA throttle - and so attenuate PID gains - when pitching down, not up. This is the aerodynamically correct direction: diving increases airspeed, so gains should attenuate; climbing reduces airspeed, so gains should stay more aggressive. iNavFlight#11952 previously investigated this same mismatch and concluded the *code* was backwards, adding a sign flip to make it match the (incorrectly worded) documentation - which would have made behavior wrong in flight. This corrects the documentation and comment instead, leaving the working code untouched. Claude-Session: https://claude.ai/code/session_01BUNPAbSF46z9QMPqTVWjv4
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can group findings by type and pick your Finding display, from Minimal to Full |
PR Summary by QodoCorrect TPA pitch compensation direction documentation
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
|
RAM / Flash usage vs. base commit
See RAM/flash optimization guide for techniques to reduce usage. |
|
Test firmware build ready — commit Download firmware for PR #11956 245 targets built. Find your board's
|
|
That's a much better explanation than it had. |
|
I might have a look at cleaning this up properly. The logic is a bit inconsistent and it would be better to not mix it up with throttle but just call it what it is, i.e. pitch TPA ... or some such term. |
No complaints here !
I think it was named TPA+PA so it wouldn't get mixed-up with the old fixedwing TPA, in its operation. |
Summary
The
tpa_pitch_compensationsetting's description and the matching inline comment incalculateTPAThtrottle()(src/main/flight/pid.c) say the virtual TPA throttle increases when pitching up. That's backwards: the code (and its owngroundCosmath, positive while diving) actually raises the virtual throttle — and so attenuates PID gains — when pitching down.That's the aerodynamically correct direction: diving increases airspeed, so gains should attenuate (matching normal TPA behavior at high airspeed); climbing reduces airspeed, so gains should stay more aggressive.
tpa_pitch_compensationis a proxy for airspeed on airframes with no airspeed sensor.Related
#11952 investigated this exact mismatch between the code and its documentation, but concluded the code was wrong and flipped its sign to match the (incorrectly worded) description — that would have made the runtime behavior backwards. This PR instead corrects the description and comment, leaving the working code untouched.
Changes
src/main/fc/settings.yaml: correctedtpa_pitch_compensationdescriptionsrc/main/flight/pid.c: corrected the matching inline comment (no logic change)docs/Settings.md: regenerated viasrc/utils/update_cli_docs.pyTesting
Documentation/comment-only change — no code logic modified, so no functional testing applies. Verified
docs/Settings.mdregeneration produces only the expected single-line diff.