Fixed wing nav: reset WP cross-track tracking state on re-engagement#11640
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Test firmware build ready — commit Download firmware for PR #11640 238 targets built. Find your board's
|
The fixed-wing waypoint cross-track controller (nav_fw_wp_tracking_accuracy) kept its rate/error state in function-local statics that were never reset. After a turn or loiter, where the controller is disengaged (needToCalculateCircularLoiter), the first sample on the next leg was computed from stale data from the previous leg, causing a small heading twitch when rejoining the course line. Re-seed the controller state to the current cross-track error while it is not actively steering, so it re-engages cleanly on the next leg.
4022174 to
9c40920
Compare
|
Looks OK to me. The filter was reset as part of #11571 but only when the position controller was reset so this adds to that. |
|
Approved by second set of eyes and also tested in Sim. No side effects. Merging. |
What
Fixes a brief, unnecessary heading twitch when a fixed-wing aircraft rejoins a
waypoint course line after a turn or loiter, with
nav_fw_wp_tracking_accuracy(waypoint course tracking) enabled.
Root cause
The cross-track controller in
updatePositionHeadingController_FW()keeps itsrate/error state in function-local
staticvariables (previousCrossTrackError,previousCrossTrackErrorUpdateTime,crossTrackErrorRateand the rate filter)that are never reset.
While the controller is disengaged — during a turn/loiter
(
needToCalculateCircularLoiter) or when the feature is off — that state freezes.On the next leg the first control sample is then computed against stale cross-track
data from the previous leg, producing a small heading kick as the aircraft
rejoins the new course line.
Fix
Re-seed the controller state to the current cross-track error whenever it is not
actively steering, so on re-engagement the error delta starts near zero and the
rate filter starts clean.
static) so the inactivebranch can reset them.
elsebranch that syncspreviousCrossTrackError/timestamp to thecurrent value, zeroes the rate, and resets the rate filter.
No new settings, no parameter-group change, no MSP/protocol change. No behavioural
change when
nav_fw_wp_tracking_accuracy = 0.Target branch
maintenance-9.x— backward-compatible bug fix per the branching guidelines.Propagates to
maintenance-10.xvia the normal merge-forward flow.Testing
nav_fw_wp_tracking_accuracyenabled, checking clean leg re-capture after turns/loiter.
Scope
Single focused fix in
navigation/navigation_fixedwing.c(~14 added / 5 removed).