FW autotrim: replace servo_autotrim_iterm_rate_limit setting with hardcoded constant#11617
Conversation
…dcoded constant The configurable CLI setting added in iNavFlight#11215 was based on a default of 2 with no empirical basis. Blackbox analysis of real flight data shows i-term rates of 4–9 units/s (median) and up to 30 units/s (90th percentile) during settled cruise flight. A hardcoded constant of 30 gives reasonable protection against turbulence-driven i-term spikes without exposing a tuning knob that pilots cannot meaningfully calibrate.
Review Summary by QodoReplace servo autotrim i-term rate limit with hardcoded constant
WalkthroughsDescription• Replace configurable servo_autotrim_iterm_rate_limit setting with hardcoded constant • Set constant to 30 based on blackbox analysis of real flight data • Remove CLI setting entry from configuration system • Simplify autotrim feature by eliminating unnecessary tuning knob Diagramflowchart LR
A["Configurable Setting<br/>servo_autotrim_iterm_rate_limit"] -->|"Replace with"| B["Hardcoded Constant<br/>SERVO_AUTOTRIM_ITERM_RATE_LIMIT = 30"]
B -->|"Based on"| C["Blackbox Analysis<br/>90th percentile = 30 units/s"]
B -->|"Applied in"| D["processContinuousServoAutotrim()"]
File Changes1. src/main/flight/servos.c
|
Code Review by Qodo
1.
|
|
Test firmware build ready — commit Download firmware for PR #11617 238 targets built. Find your board's
|
Summary
Removes the
servo_autotrim_iterm_rate_limitCLI setting introduced in #11215 and replaces it with the hardcoded constantSERVO_AUTOTRIM_ITERM_RATE_LIMIT 30.Blackbox analysis of real flight i-term data shows:
planeIsFlyingStraightgyro guard already rejects most unsettled post-maneuver windows, the rate check also protects against turbulence-driven i-term spikes during otherwise-quiet cruiseA value of 30 (the ~90th percentile) gives appropriate protection without exposing a tuning knob that pilots cannot meaningfully calibrate.
Changes
src/main/flight/servos.c: Add#define SERVO_AUTOTRIM_ITERM_RATE_LIMIT 30grouped with the other autotrim defines; replaceservoConfig()->servo_autotrim_iterm_rate_limitwith the constantsrc/main/flight/servos.h: Removeuint8_t servo_autotrim_iterm_rate_limitfromservoConfig_tsrc/main/fc/settings.yaml: Remove theservo_autotrim_iterm_rate_limitsetting entryNo PG version bump required because the tunable setting was for testing only and never released. Also field was at the end of
servoConfig_t, so existing EEPROM blocks may load safely anyway.Thanks @error414 !