Skip to content

Plane: rework fbwa glide failsafe - #34351

Closed
IamPete1 wants to merge 2 commits into
ArduPilot:masterfrom
IamPete1:plane_fbwa_glide
Closed

IamPete1 wants to merge 2 commits into
ArduPilot:masterfrom
IamPete1:plane_fbwa_glide

Conversation

@IamPete1

@IamPete1 IamPete1 commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Summary

This moves away from using the output limit method in plane glide failsafe. The use of output limit results in full reverse throttle in a reverse throttle setup. This changes to using 0 scaled output and then not applying throttle limits. Currently throttle limits are applied so you would actually get throttle min.

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Description

This adds a test for the glide fail-safe zeroing throttle for both the normal and reversible case. Spotted while pondering #34277

There could be a argument for still applying throttle min as now for IC engines. This at least brings the behavior inline with the fail safe description: "2:FBWA at zero throttle"

@tridge

tridge commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Deprecated — see below for the updated review.

Previous review (2026-09-10)

Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting.

Reviewed at head 94d79fb310. Full report: https://uav.tridgell.net/DevCallReviews/2026_09_10_AIReview/devcall_pr_reviews.html#pr34351

Verdict: COMMENT — no blockers. The functional change is correct, safe and well scoped, and the limit bypass cannot leak out of the failsafe. But one of the two new autotests passes unmodified on master, and the "full reverse throttle" motivation in the description isn't reproducible.

Everything below marked "proved by mutation" was reproduced by two independent SITL runs, each building this head with ArduPlane/ reverted to the merge base 4891432f35 while keeping the new tests.

FBWAGlideThrottleReverse passes on master, so it can't catch the bug it's named for

Tools/autotest/arduplane.py:1614. With ArduPlane/ reverted to the base and the new tests kept:

test PR head base ArduPlane/ (fix reverted)
FBWAGlideThrottle servo3_raw=1000 PASS servo3_raw=1200 FAIL ("Wrong value")
FBWAGlideThrottleReverse servo3_raw=1500 PASS servo3_raw=1500 PASS

The first is a proper regression test and worth keeping. The second asserts SERVO3_TRIM, which is what master already produces — and it stays 1500 even with USE_REV_THRUST=65535 (the FBWA bit, which the test doesn't set) across 20 steady-state samples. Either drop it, point it at a configuration where the base build actually misbehaves, or keep it as coverage of the angle-type throttle channel and say so in the docstring rather than claiming it covers a bug.

The "full reverse throttle" premise isn't reachable on master

The removed SRV_Channels::set_output_limit(k_throttle, Limit::MIN) never reaches an output — it's overwritten later in the same loop iteration:

  • ModeFBWA::update() runs from FAST_TASK(update_control_mode) (ArduPlane/Plane.cpp:65), before FAST_TASK(stabilize) (Plane.cpp:66) which calls ModeFBWA::run().
  • set_output_limit sets have_pwm_mask (libraries/SRV_Channel/SRV_Channel.cpp:249), making calc_pwm() early-return.
  • run() then calls output_pilot_throttle() → set_output_scaled(), and that clears the bit again: SRV_Channel::have_pwm_mask &= ~functions[function].channel_mask; (libraries/SRV_Channel/SRV_Channel_aux.cpp:621).

Under RC failsafe the scaled value is exactly 0: failsafe.rc_failsafe ⟹ has_valid_input() false (ArduPlane/RC_Channel_Plane.cpp:20) ⟹ get_adjusted_throttle_input() returns 0.0 (ArduPlane/reverse_thrust.cpp:156). The only thing that moved it off zero was apply_throttle_limits() clamping up to THR_MIN — and for a reversible setup servos.cpp:546-549 forces min_throttle = 0 whenever reverse thrust isn't currently allowed, so the reverse case already landed on 0 → SERVO3_TRIM. That matches the measurement above.

The fix is still worth doing — the real defect is that the glide failsafe output THR_MIN rather than zero, which is exactly what FS_SHORT_ACTN=2's own docs ("FBWA at zero throttle") promise. The summary would just be more useful to a future reader if it said that instead.

in_fbwa_glide_failsafe() misses two of the three ways into an FBWA glide

ArduPlane/events.cpp:363 keys only on g.fs_action_short. But FS_LONG_ACTN=2 (2:Glide, Parameters.cpp:449) also puts the vehicle in FBWA under RC failsafe via FS_ACTION_LONG_GLIDE (events.cpp:151), as does emergency_landing (events.cpp:143).

Reproduced on the PR build: with FS_SHORT_ACTN=0, FS_LONG_ACTN=2, THR_MIN=20, the vehicle sits in FBWA under RC failsafe at servo3_raw=1200 for 12 consecutive samples — still THR_MIN, fix not applied.

This is pre-existing (master's condition was the same), so not a regression. But the new helper is named for the general case and commented "return true if currently in a fbwa glide failsafe", which is now misleading. Either widen it (|| g.fs_action_long == FS_ACTION_LONG_GLIDE || emergency_landing, gated on failsafe.state) or narrow the name/comment to the short-failsafe glide. Note the new tests set both actions to 2, so they don't distinguish the paths.

On the IC-engine question you raise in the description

ICE_IDLE_PCT survives; a bare THR_MIN idle doesn't. apply_throttle_limits() folds in ice_control.get_min_throttle_pct() at servos.cpp:542 and that is now bypassed — but AP_ICEngine::throttle_override() runs later and unconditionally in set_servos() (servos.cpp:962) and re-raises the throttle to the idle percentage whenever the engine is running (AP_ICEngine.cpp:535). So ICE_ENABLE=1 users keep their idle through the glide. The exposed case is a piston or turbine setup with ICE_ENABLE=0 relying on THR_MIN alone as an idle floor; those now get a true zero and the engine may stop. Probably worth a release-note line and a sentence in the PR body.

Minor

  • ArduPlane/Attitude.cpp:115 is dead code, before and after. stick_mixing_enabled() already returns false at Attitude.cpp:84 when !rc().has_valid_input(), which is false whenever failsafe.rc_failsafe is set. That also means the newly added control_mode == &mode_fbwa term is behaviourally inert — checked specifically, because on paper it narrows the old condition. Deleting the block would be tidier than rewriting it, but it's harmless either way.
  • events.cpp:364 puts the opening brace on the same line where the rest of that file uses a brace on its own line; events.cpp:367 is indented one space past the lines it aligns with.
  • arduplane.py:1618 breaks a lambda across its own parameter list purely to satisfy flake8 — self.assert_servo_channel_range(3, 1490, 1510) already exists (vehicle_test_suite.py:8983) and reads better.
  • arduplane.py:1584's comment "takes off in FBWA demanding throttle" is wrong: it takes off in TAKEOFF mode. Since TAKEOFF takes no short-failsafe action (events.cpp:93), the mode change in both tests actually comes from the long failsafe — the tests only work because they also set FS_LONG_ACTN=2.

What was checked and is clean

The bypass cannot leak. use_throttle_limits() is consulted from exactly one place, ArduPlane/servos.cpp:624. There's no cached boolean: ModeFBWA::use_throttle_limits() recomputes in_fbwa_glide_failsafe() live, and that requires control_mode == &mode_fbwa, so the bypass is structurally impossible outside FBWA and self-clears the instant the failsafe or the mode ends. Differential thrust is handled — servos_twin_engine_mix() (servos.cpp:788) derives k_throttleLeft/k_throttleRight from get_output_scaled(k_throttle) inside servos_output(), which runs after set_throttle(); with throttle 0 it takes the throttle <= 0 branch and writes 0 to both. On master they followed THR_MIN too, so this fixes them as well. Battery compensation is multiplicative on 0, and every suppress_throttle() fallback writes either 0 or get_throttle_input(true), which is 0 under RC failsafe. Both new tests are registered in tests1b(); the use_throttle_limits() declaration in mode.h:637 is correctly outside the #if MODE_AUTOLAND_ENABLED block; git diff --check is clean and flake8 passes on the autotest; the framework auto-restores the customised SITL command line so model="plane-revthrust" doesn't leak into later tests. Both new tests were run 12 times back to back on the PR build — 24/24, no flakes.

No conflict with #34277 — only Plane.h overlaps, in a different section. Semantically they compose: #34277's cached throttle limits are invalidated when use_throttle_limits() is false, so a tiltrotor in the glide failsafe samples the unlimited zero, which is the desired result. Whichever merges second needs a trivial Plane.h rebase.

Reviewed by Claude plus an independent Codex pass that was shown only the PR number, never these findings; it independently reached the same conclusion about FBWAGlideThrottleReverse from its own reproduction.

@Hwurzburg Hwurzburg added the WikiNeeded needs wiki update label Sep 10, 2026

@Hwurzburg Hwurzburg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THR_MIN when gliding has a practical application of lowering drag....while the action is primarily intended to allow for a controlled crash if the failsafe persists and no pilot control option (RC for GCS FS, GCS for RC failsafe) exists, extending the glide to allow pilot intervention seems desireable....also the ICE engine dying absolutely complicates any recovery....

@IamPete1

Copy link
Copy Markdown
Member Author

I think we need to decide exactly what behavior we want before going forward, I have marked for the dev call.

@IamPete1
IamPete1 marked this pull request as draft September 10, 2026 13:22
@tridge

tridge commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Deprecated — see below for the updated review.

Previous review (2026-09-10)

Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting.

Re-reviewed at head 94d79fb310 — the same head as my earlier comment above, which is superseded. Full report: https://uav.tridgell.net/DevCallReviews/2026_09_15/devcall_pr_reviews.html#pr34351

The code has not changed since, so all 8 findings from that comment are still open and none is resolved. I am reposting rather than editing because two things are materially different: one finding is stronger than I stated it, and an independent cross-check found a throttle writer I had explicitly ruled out. Everything else below is a re-raise, not a new complaint.

Verdict: COMMENT. Noting @IamPete1 has marked this for the dev call pending a decision on the intended behaviour, and @Hwurzburg has argued against the change on drag and ICE-recovery grounds — that process outranks all of this. These are input to that discussion, not a merge gate.

BUG (strengthened) — the bypass also removes idle for ICE_ENABLE=1 aircraft, not just ICE_ENABLE=0

My previous comment said ICE_IDLE_PCT survives the bypass and only ICE_ENABLE=0 setups were exposed. That was too narrow. ICE_IDLE_PCT defaults to 0 (AP_ICEngine.cpp:133), and the idle re-raise in AP_ICEngine::throttle_override() is gated on it being non-zero (:530, :535-539). ICE_IDLE_RPM also defaults to -1, so the idle governor does not raise it either.

So for ICE_ENABLE=1, ICE_IDLE_PCT=0 (default), THR_MIN=15:

  • Before: apply_throttle_limits() took min_throttle = MAX(aparm.throttle_min, get_min_throttle_pct()) = 15 (ArduPlane/servos.cpp:534-545) and clamped the scaled 0 up to 15 — the engine kept idling through the glide.
  • After: use_throttle_limits() is false (servos.cpp:624), the whole function is skipped, throttle stays at 0.
  • The later ICE hook at servos.cpp:963-966 cannot rescue it: with min_throttle_pct == 0 the ICE_RUNNING branch is skipped and the rest are start/redline/disarmed, so throttle_override() returns false.

The engine can therefore stop during an RC-failsafe glide on an ICE aircraft that never touched ICE_IDLE_PCT. This is exactly @Hwurzburg's concern with a code path attached. If the dev call goes ahead with zeroing, this wants a release-note line, and arguably apply_throttle_limits()'s ICE floor should survive even when the mode declines the rest of the limits.

ISSUE (new) — force_flare() can restore THR_MIN after the new zero

My previous comment said the ICE hook was the only later writer of k_throttle. That was wrong. Plane::force_flare() (ArduPlane/servos.cpp:824) runs at servos.cpp:1049, after the ICE hook, and when active writes MAX(aparm.throttle_min, 0) to k_throttle and both differential-throttle channels (:852-856). Its conditions — a HAL_QUADPLANE_ENABLED build, armed, a manual-throttle mode, flare_mode != FLARE_DISABLED, throttle_at_zero() — are all satisfiable in an FBWA RC-failsafe glide on a quadplane with the flare option configured.

Not a regression (master already produced THR_MIN there), but on that configuration the PR does not achieve the zero it intends. Worth considering alongside the ICE case when the behaviour is decided.

Re-raised from the previous round

FBWAGlideThrottleReverse does not test the bug in its name (Tools/autotest/arduplane.py:1594-1622). Previously proved by mutation: with ArduPlane/ reverted to the merge base, FBWAGlideThrottle failed (servo3_raw=1200) while FBWAGlideThrottleReverse still passed (1500). The test sets THR_MIN=-100 but leaves USE_REV_THRUST default, so allow_reverse_thrust() is false for FBWA (reverse_thrust.cpp:100-102) and apply_throttle_limits() forces min_throttle = 0 (servos.cpp:547-549) — the base already outputs 0 → SERVO3_TRIM = 1500, exactly what the test asserts. The cross-check adds that setting the reverse bit would not fix it either, since 0 also lies inside [-100, THR_MAX]. FBWAGlideThrottle is a genuine regression test; this one either wants dropping, retargeting, or a reworded docstring.

The description's "full reverse throttle" premise is not reachable on master. update_control_mode precedes stabilize precedes set_servos (Plane.cpp:64-67), and set_output_scaled() clears the have_pwm_mask (SRV_Channel_aux.cpp:617-621) that set_output_limit had set (SRV_Channel.cpp:251, early-return at :226) — so the removed Limit::MIN never reached an output. The real defect being fixed is that the glide outputs THR_MIN rather than the zero its own parameter doc promises. That is a stronger justification and probably the framing the dev call needs.

in_fbwa_glide_failsafe() covers one of three ways into an FBWA glide (events.cpp:364-368). It keys on g.fs_action_short == FS_ACTION_SHORT_FBWA, so with FS_SHORT_ACTN != 2 it misses emergency_landing (set_mode(mode_fbwa) at events.cpp:144) and FS_ACTION_LONG_GLIDE (events.cpp:152). Line refs corrected from my previous comment, which cited 143 and 151 — those are the enclosing if/else if. Previously reproduced in SITL with FS_SHORT_ACTN=0, FS_LONG_ACTN=2, THR_MIN=20: FBWA under RC failsafe at 1200 for 12 consecutive samples, fix not applied. Pre-existing — master's inline condition was identical — but the helper is now named and commented for the general case. Both new tests set both actions to 2, so they enter by the long path while satisfying the short-action predicate and cannot distinguish the two.

Minor, unchanged: Attitude.cpp:115 is dead code before and after (stick_mixing_enabled() already returns false at :84-87 when !rc().has_valid_input()); events.cpp:364 brace style and :367 indentation; arduplane.py:1615-1619 could use the existing assert_servo_channel_range(3, 1490, 1510); arduplane.py:1584's "takes off in FBWA" comment is wrong, since the call is takeoff(50, mode='TAKEOFF') and TAKEOFF takes no short-failsafe action (events.cpp:93-102).

Checked and correct

The bypass cannot latch or leak (single consumer at servos.cpp:624, recomputed live in mode_fbwa.cpp:53-62, failsafe.rc_failsafe is a plain set/clear at radio.cpp:244/:260). Throttle slew is disabled in FBWA (servos.cpp:33-39) so the single-sample assertions are not racing a ramp, and both tests ran 12× clean previously. The two tests assert different constants because the throttle function is angle-type only when have_reverse_thrust() (radio.cpp:39) — both are right. plane-revthrust is a real SITL model (SIM_Plane.cpp:68). Commit split is correct: one ArduPlane/ commit, one Tools/autotest/ commit. Differential thrust follows to zero via servos_twin_engine_mix() (servos.cpp:780), subject to the force_flare() exception above.

Very minor: TECS_controller.set_throttle_min()/set_throttle_max() live inside apply_throttle_limits() (servos.cpp:604-605) so they freeze while bypassed. Harmless — FBWA does not use TECS throttle and they are re-pushed at loop rate. ModeManual already has the same property; noted only so it is not mistaken for a new problem later.

Reviewed by Claude + an independent Codex cross-check, which confirmed the ICE bug, corrected the two line references, narrowed the failsafe-coverage finding, and contributed the force_flare() writer.

@tridge

tridge commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

There could be a argument for still applying throttle min as now for IC engines

I'm happy with it being zero, but if you'd like to apply the min for IC enginers that is OK too (just needs docs). This was originally added for electric planes to meet safety requirements for a competition

Comment thread ArduPlane/events.cpp Resolved
Comment thread ArduPlane/Attitude.cpp Resolved
Comment thread ArduPlane/mode_fbwa.cpp Resolved
Comment thread ArduPlane/mode_fbwa.cpp Resolved
@IamPete1
IamPete1 marked this pull request as ready for review September 16, 2026 16:54
@IamPete1 IamPete1 changed the title Plane: don't use output limit in fbwa glide failsafe Plane: rework fbwa glide failsafe Sep 16, 2026
@AP-Review

AP-Review commented Sep 16, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-09-16)

Automated review note — AI-generated (Claude), validated against the live diff (Claude + Codex cross-checked). Please sanity-check before acting.
Verdict: COMMENT

Re-reviewed at head e49b990467 (you were last told 94d79fb310); my earlier comment above is superseded.

Full report: https://uav.tridgell.net/DevCallReviews/followups/2026_09_17_0616/devcall_pr_reviews.html#pr34351


Previous round: 2 of 8 findings resolved, 1 settled in the thread, 5 still open. The rework does exactly what I asked for on the coverage finding — all four failsafe routes into an FBWA glide now set the flag. But replacing the live condition with a latched flag introduced a new problem, and both my own pass and an independent cross-check reproduced it separately in SITL. Verdict: COMMENT → REQUEST CHANGES on that alone; the design question the dev call is settling is unaffected by it.

BUG (new) — the glide flag latches after the failsafe clears

should_glide has only two writers of false: ArduPlane/events.cpp:255, inside rc_failsafe_short_off_event() and gated on both control_mode_reason == RADIO_FAILSAFE and the mode restore succeeding, and ArduPlane/mode_fbwa.cpp:7 in _enter(). failsafe_long_off_event() (events.cpp:261-273) clears failsafe.state and never touches the flag, and re-selecting FBWA does not help because Plane::set_mode() early-returns at ArduPlane/system.cpp:249-256 when already in the mode — so it neither runs _enter() nor updates control_mode_reason.

Measured in SITL by two independent passes, THR_MIN=20, throttle stick 1800 and roll stick 1900 after recovery, this head against the same tree with ArduPlane/ reverted to the PR's parent b2b1b3d279:

scenario during the glide after "Failsafe Cleared" (head) after cleared (base)
RC long failsafe, FS_SHORT_ACTN=2, FS_LONG_ACTN=2 servo3=1000 servo3=1000, nav_roll=0.00 servo3=1800, nav_roll=51.85
GCS failsafe, FS_LONG_ACTN=2, RC never lost servo3=1000 servo3=1000, nav_roll=0.00 servo3=1800, nav_roll=51.94
short failsafe only, already in FBWA servo3=1000 servo3=1000, nav_roll=0.00 n/a — master self-clears

The third row is the everyday case: if the pilot is already in FBWA when the short failsafe fires, set_mode(mode_fbwa, RADIO_FAILSAFE) early-returns without updating control_mode_reason, so events.cpp:253 is false on recovery and the clear never runs — the log shows no "Flight mode ... restored" message. The GCS row is the worst: RC is valid throughout, the stick was producing 1800 before the failsafe, and afterwards the aircraft holds zero throttle and ignores the sticks. Master never glided on that path at all. Disarm/rearm does not clear it either; only switching mode away and back does.

Suggested invariant: clear it in failsafe_long_off_event() and unconditionally in rc_failsafe_short_off_event(), or make glide_failsafe_active() additionally require failsafe.state != FAILSAFE_NONE — while keeping @peterbarker's never-saw-a-receiver case, which the flag approach does fix.

Nothing tests the recovery side. Both new tests assert only while the failsafe is active (the assert at Tools/autotest/arduplane.py:1618 lands before "RC Long Failsafe Cleared"), then fly_home_land_and_disarm() changes mode and masks the latch. The existing GCSFailsafe FBWA-glide subtest does the same.

BUG (new) — the latched attitude override also pins AUTOTUNE

ArduPlane/mode_autotune.cpp:14 is a one-line forward to plane.mode_fbwa.update(), which holds the if (should_glide) { nav_roll_cd = 0; nav_pitch_cd = 0; } block at ArduPlane/mode_fbwa.cpp:28-32. With the flag latched, switching from the glide into AUTOTUNE demands zero roll and pitch: measured after GCS recovery with roll stick 1900, nav_roll=0.00 at this head against 51.95 at base (throttle 1800 in both — AUTOTUNE has its own run(), so only attitude is affected). Same root cause; fixing the latch fixes this too.

ISSUE — the long/GCS/emergency-landing paths now cut throttle, and the docs don't say so

ArduPlane/Parameters.cpp:442 documents FS_SHORT_ACTN as 2:FBWA at zero throttle, but :449 still documents FS_LONG_ACTN as just 2:Glide, described only as "will change to FBWA", and libraries/RC_Channel/RC_Channel.h:327 (EMERGENCY_LANDING_EN) says only "Force long FS action to FBWA". After this PR all three zero the throttle. Given @tridge's "I'm happy with it being zero ... just needs docs", this is the docs half of that. WikiNeeded is already on the PR.

Resolved since last round

  • in_fbwa_glide_failsafe() now covers every way into an FBWA glide. All four sites set the flag — events.cpp:39, 85, 147, 209 — covering FS_ACTION_SHORT_FBWA, emergency_landing (short and long) and FS_ACTION_LONG_GLIDE in both switch groups. A probe exercising all six direct entries got servo3=1000 in every case. This was my main finding last round.
  • Attitude.cpp:115 is no longer dead code. should_glide no longer implies !rc().has_valid_input(), so in a GCS-failsafe glide (RC valid) that check is what suppresses stick mixing — which also answers @Georacer's question on that line.

Settled — dropping as a blocker

The ICE idle finding (ICE_ENABLE=1 with the default ICE_IDLE_PCT=0 loses the idle floor) is still true in code: servos.cpp:624 and mode_fbwa.cpp:61-70 are unchanged. But @tridge has decided it — "I'm happy with it being zero, but if you'd like to apply the min for IC engines that is OK too (just needs docs)" — and @Georacer's "a glide failsafe should stop the propeller" agrees. So only the docs item above remains from it, and I won't raise it again.

Re-raised — unchanged since last round

  • force_flare() restores THR_MIN after the new zero. ArduPlane/servos.cpp:852-856, called at :1049 after the mode's throttle write. Last round this was source-level reasoning; it is now measured — servo3=1200 with flare enabled, 1000 with it disabled. servos.cpp is byte-identical to the previous head, so this is a re-raise, not a regression.
  • FBWAGlideThrottleReverse still does not test the bug in its name. Re-proved by mutation, independently, twice: with only ArduPlane/ reverted to the parent and the new tests kept, FBWAGlideThrottle fails (1200 against an expected 1000) while FBWAGlideThrottleReverse passes at 1500. arduplane.py:1622-1650 either wants dropping, retargeting, or a reworded docstring.
  • The description's "full reverse throttle" premise is not reachable on master — the base build already outputs SERVO3_TRIM in that configuration, which is what the mutation above shows. The real defect being fixed is that the glide outputs THR_MIN rather than the zero its own parameter doc promises.
  • Style: events.cpp:370 puts a function definition's opening brace on the same line; :37 is if( without a space; :149 and :211 have a stray blank line before } else if.
  • Autotest: arduplane.py:1643-1648 is equivalent to the existing assert_servo_channel_range(3, 1490, 1510); :1612 still says "takes off in FBWA" where the call is takeoff(50, mode='TAKEOFF').

CI

80 passing, 1 failing, 0 cancelled. The failure is autotest (sitltest-plane-tests1a) at exactly 2700 s. I first read that as a job timeout; the cross-check found the job annotation actually reports runner communication loss, and the log blob is no longer retrievable, so the cause is unconfirmed. No plane-tests1a artifact was uploaded where the other three groups uploaded theirs. The whole group passes locally at this head (77 passed, 1 skipped) and recent master runs of test_sitl_plane.yml are green — worth a re-run rather than reading as a fault in this PR.

@Georacer Georacer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much improved since the last time!

I've left one more question.

Comment thread ArduPlane/Attitude.cpp
}

if (failsafe.rc_failsafe && g.fs_action_short == FS_ACTION_SHORT_FBWA) {
if (in_fbwa_glide_failsafe()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I traced the code and you are now stopping the mixing on FS_ACTION_LONG_GLIDE, which seems reasonable.

One thing: you usually clear should_glide in every void Plane::rc_failsafe_short_off_event(). Should you be doing the same in void Plane::failsafe_long_off_event(ModeReason reason)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its only done in rc_failsafe_short_off_event because it restores the flight mode. Originally entering FBWA would clear the glide flag, but you may have been flying in FBWA then had a glide failsafe (also in FBWA) then be restored to FBWA, in this case the glide is not cleared because the mode entry code it not run (since were already in the mode).

For the long failsafe there is no expectation of restoring flight mode so I think it would be unexpected to have throttle suddenly come to life.

I guess the way to really make this clear would be to have a glide failsafe as its own mode.....

@Georacer

Copy link
Copy Markdown
Contributor

Do read the AI review as well. The bug reported seems valid, as well as the items force_flare() and FBWAGlideThrottleReverse from the last time.

@AP-Review

AP-Review commented Oct 30, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-10-30)

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: REQUEST CHANGES

Reviewed at head 0fbb3fc6bb.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/ardupilot/34351/1.html#pr34351

This is still the same as the e49b990 review: the glide flag stays set after a failsafe clears, so changes are needed before merge.

Since then the branch has only been rebased onto master, which also fixed the if( spacing. None of the earlier findings has been addressed.

Blocking

  1. ArduPlane/events.cpp:255 Glide flag latches (still open): after an RC long, GCS, or already-in-FBWA short failsafe clears, FBWA keeps zero throttle and zero roll/pitch with valid sticks. Switching from the glide to AUTOTUNE also zeroes roll/pitch, because AUTOTUNE uses mode_fbwa.update(). Clear should_glide in failsafe_long_off_event() and unconditionally in rc_failsafe_short_off_event(), and also when FBWA is left (a ModeFBWA::_exit()). This is the question @Georacer asked on the long-off event.

Should fix

  • Tools/autotest/arduplane.py:1607 Recovery untested (still open): both tests assert only during the failsafe and then switch to AUTO. Add a check after "Failsafe Cleared", while still in FBWA, that throttle and roll follow the sticks.
  • ArduPlane/events.cpp:147 Docs (still open): the long, GCS and emergency-landing glides now cut throttle to zero, but FS_LONG_ACTN (2:Glide, ArduPlane/Parameters.cpp:449) and EMERGENCY_LANDING_EN (libraries/RC_Channel/RC_Channel.h:327) don't say so.
Minor (3)
  • ArduPlane/mode_fbwa.cpp:53 force_flare (still open): with a LANDING_FLARE switch on and the throttle stick at idle, force_flare() (ArduPlane/servos.cpp:852-856) writes THR_MIN back after this zero. Exclude the glide there or document the exception.
  • Tools/autotest/arduplane.py:1630 Reverse test comment (still open): base already outputs SERVO3_TRIM (1500) in this config, so "the old code drove full reverse" is wrong, and so is the PR description. Keep the test as zero-thrust coverage and reword the comment and docstring.
  • ArduPlane/events.cpp:372 Style (still open): this function's opening brace is on the definition line. There are stray blank lines at :149 and :211, and arduplane.py:1600 says "takes off in FBWA" but takes off in TAKEOFF mode.

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Global Size Summary (Total Flash delta in bytes)

Built from 3acd2be rebased onto 3bf2129

Board Periph tracker blimp bootloader copter heli iofw plane rover sub
DrotekP3Pro _ _ _ * _ _ _ _ _ _
Durandal _ * * _ * * _ +108 * *
Hitec-Airspeed * _ _ _ _ _ _ _ _ _
KakuteF7 _ * * _ * * _ +84 * *
MambaH743v4 _ * * _ * * _ +68 * *
MatekF405-CAN _ _ _ * _ _ _ _ _ _
MatekF405 _ * * _ * * _ +84 * *
MatekH743-bdshot _ * * _ * * _ +84 * *
Pixhawk1-1M _ * * _ * * _ +104 * *
disco _ * * _ * * _ -72 * *
f103-GPS * _ _ _ _ _ _ _ _ _

@AP-Review

Copy link
Copy Markdown

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: REQUEST CHANGES

Reviewed at head 3acd2bef05.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/ardupilot/34351/2.html#pr34351

One blocker remains: a short RC failsafe taken while already in FBWA still leaves the glide on after RC returns.

Since the last review, the new ModeFBWA::_exit() fixes the AUTOTUNE case and the helper brace. Per your reply, the long/GCS glide persisting until a mode change is now treated as intended.

Blocking

  1. ArduPlane/events.cpp:255 Short failsafe from FBWA latches the glide: set_mode() returns early when already in FBWA, so control_mode_reason never becomes RADIO_FAILSAFE. This clear is skipped, and throttle stays at zero with roll/pitch held level after RC returns, until the pilot changes mode. Call mode_fbwa.set_glide_failsafe(false) unconditionally in rc_failsafe_short_off_event(); this doesn't affect the long-failsafe persistence.

Should fix

  • Tools/autotest/arduplane.py:1607 Recovery untested (still open): both tests switch to AUTO straight after clearing the failsafe. Add a short-only loss from pilot-selected FBWA and assert throttle and roll follow the sticks after "RC Short Failsafe Cleared".
  • ArduPlane/events.cpp:147 Docs (still open): FS_LONG_ACTN (2:Glide) and EMERGENCY_LANDING_EN don't say the glide cuts throttle to zero, holds attitude, ignores sticks and now persists until a different mode is selected.
Minor (3)
  • ArduPlane/mode_fbwa.cpp:61 force_flare (still open): with a LANDING_FLARE switch on and the throttle input at idle, force_flare() writes THR_MIN over this zero. Exclude the glide there or document it.
  • Tools/autotest/arduplane.py:1630 Reverse test comment (still open): the base already outputs SERVO3_TRIM here, so "the old code drove full reverse" is wrong. Reword the comment; the test is still good zero-thrust coverage.
  • Tools/autotest/arduplane.py:1600 Takeoff comment (still open): says "takes off in FBWA" but the takeoff is in TAKEOFF mode.

Withdrawn: clearing the glide on long/GCS recovery, now intended per your reply, and the blank-line nits.

@IamPete1

IamPete1 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

I have done a PR to get a feel for what it might look like to make the glide failsafe its own mode. #34971

@IamPete1

IamPete1 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

The flash cost of the dedicated mode is only double this rework, so I think the dedicate mode is the better option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants