Enable Fixed Wing Auto Speed During Waypoint Mission - #11757
Conversation
PR Summary by QodoEnable fixed-wing Auto Speed from waypoint mission speeds
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1. Stale autospeed active flag
|
| bool isFixedwingAutoSpeedActive(void) | ||
| { | ||
| return autoSpeedIsActive; | ||
| } |
There was a problem hiding this comment.
1. Stale autospeed active flag 🐞 Bug ≡ Correctness
isFixedwingAutoSpeedActive() now returns a cached flag that is only updated inside applyAutoSpeedThrottleDemand(), but fixed-wing throttle logic checks isFixedwingAutoSpeedActive() earlier in the same navigation loop. When Auto Speed becomes disabled, the fixed-wing controller can incorrectly skip its normal throttle path for one cycle, leaving rcCommand[THROTTLE] without the expected nav throttle control for that iteration.
Agent Prompt
### Issue description
`isFixedwingAutoSpeedActive()` now returns a cached variable (`autoSpeedIsActive`) that is only set/cleared inside `applyAutoSpeedThrottleDemand()`. But the fixed-wing nav controller consults `isFixedwingAutoSpeedActive()` before `applyAutoSpeedThrottleDemand()` is called in the same control loop, so it can use stale state (especially on disable), skipping its normal throttle update for one loop.
### Issue Context
`applyFixedWingPitchRollThrottleController()` uses `isFixedwingAutoSpeedActive()` to decide whether to run the normal throttle correction path. `applyAutoSpeedThrottleDemand()` (which updates `autoSpeedIsActive`) is invoked after the fixed-wing controller from `applyWaypointNavigationAndAltitudeHold()`.
### Fix Focus Areas
- src/main/navigation/navigation_fixedwing.c[890-923]
- src/main/navigation/navigation_fixedwing.c[674-735]
- src/main/navigation/navigation.c[4447-4458]
### Proposed fix
Make `isFixedwingAutoSpeedActive()` reflect the *current* enablement conditions (e.g., `STATE(AIRPLANE) && isAutoSpeedEnabled()`), not a cached value updated later. If you still need a cached “last applied” flag for OSD/telemetry, keep it separate (e.g., `autoSpeedWasAppliedThisLoop`) and don’t use it for control-path gating.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Test firmware build ready — commit Download firmware for PR #11757 243 targets built. Find your board's
|
Adds ability to use fixed wing Auto Speed mode with waypoint missions.
Usage:
fw_auto_speed_channel) and the ability to switch between ground or airspeed as the speed reference.Notes:
Auto Speed max and min speed settings,
fw_auto_speed_max_speedandfw_auto_speed_min_speed, take precedence over the waypoint mission speed settings.PR includes provision to allow use of airspeed as the speed reference during Nav but it's currently not implemented (todo).
Appears to work as expected from HITL testing.