Repository navigation
Conversation
ec04cc1 to
94d79fb
Compare
Previous review (2026-09-10)Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting. Reviewed at head 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
|
| 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 fromFAST_TASK(update_control_mode)(ArduPlane/Plane.cpp:65), beforeFAST_TASK(stabilize)(Plane.cpp:66) which callsModeFBWA::run().set_output_limitsetshave_pwm_mask(libraries/SRV_Channel/SRV_Channel.cpp:249), makingcalc_pwm()early-return.run()then callsoutput_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:115is dead code, before and after.stick_mixing_enabled()already returns false atAttitude.cpp:84when!rc().has_valid_input(), which is false wheneverfailsafe.rc_failsafeis set. That also means the newly addedcontrol_mode == &mode_fbwaterm 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:364puts the opening brace on the same line where the rest of that file uses a brace on its own line;events.cpp:367is indented one space past the lines it aligns with.arduplane.py:1618breaks 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 setFS_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
left a comment
There was a problem hiding this comment.
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....
|
I think we need to decide exactly what behavior we want before going forward, I have marked for the dev call. |
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 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
|
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 |
94d79fb to
e49b990
Compare
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. Re-reviewed at head 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
Measured in SITL by two independent passes,
The third row is the everyday case: if the pilot is already in FBWA when the short failsafe fires, Suggested invariant: clear it in Nothing tests the recovery side. Both new tests assert only while the failsafe is active (the assert at BUG (new) — the latched attitude override also pins AUTOTUNE
ISSUE — the long/GCS/emergency-landing paths now cut throttle, and the docs don't say so
Resolved since last round
Settled — dropping as a blockerThe ICE idle finding ( Re-raised — unchanged since last round
CI80 passing, 1 failing, 0 cancelled. The failure is |
Georacer
left a comment
There was a problem hiding this comment.
Much improved since the last time!
I've left one more question.
| } | ||
|
|
||
| if (failsafe.rc_failsafe && g.fs_action_short == FS_ACTION_SHORT_FBWA) { | ||
| if (in_fbwa_glide_failsafe()) { |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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.....
|
Do read the AI review as well. The bug reported seems valid, as well as the items |
e49b990 to
0fbb3fc
Compare
Previous review (2026-10-30)Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head 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 Blocking
Should fix
Minor (3)
|
Global Size Summary (Total Flash delta in bytes)Built from 3acd2be rebased onto 3bf2129
|
0fbb3fc to
3acd2be
Compare
|
Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head 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 Blocking
Should fix
Minor (3)
Withdrawn: clearing the glide on long/GCS recovery, now intended per your reply, and the blank-line nits. |
|
I have done a PR to get a feel for what it might look like to make the glide failsafe its own mode. #34971 |
|
The flash cost of the dedicated mode is only double this rework, so I think the dedicate mode is the better option. |
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)
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"