AP_Scripting: VTOL-quicktune restrict tuning to QSTABILIZE/QHOVER/QLOITER - #33025
Open
rwoneill wants to merge 2 commits into
Open
AP_Scripting: VTOL-quicktune restrict tuning to QSTABILIZE/QHOVER/QLOITER#33025rwoneill wants to merge 2 commits into
rwoneill wants to merge 2 commits into
Conversation
…ITER VTOL-quicktune only gated on arming + vehicle:get_likely_flying(). On a quadplane flying fixed-wing, the VTOL rate controllers are dormant, so AC_AttitudeControl:get_rpy_srate() returns ~0 and the oscillation gate never trips. If the tune-position switch is bumped during a fixed-wing leg, Q_A_RAT_*_D ramps unbounded; on the transition back to VTOL the inflated gains drive the controller unstable. This patch refuses to tune unless the quadplane is in QSTABILIZE, QHOVER, or QLOITER -- the pilot-controlled hover modes the applet's documentation was written for. Auto-descent VTOL modes (QLAND/QRTL), QAUTOTUNE, and QACRO are also excluded. If the pilot transitions out of a tunable mode mid-tune, gains revert via the existing abort path. The check is a no-op for multicopter, where rate controllers are always active and the existing slew-rate gate is sufficient. Signed-off-by: Roger O'Neill <rwoneill@users.noreply.github.com>
tridge
requested changes
May 11, 2026
| if is_quadplane then | ||
| local m = vehicle:get_mode() | ||
| -- QSTABILIZE=17, QHOVER=18, QLOITER=19 | ||
| in_tunable_mode = (m == 17 or m == 18 or m == 19) |
Contributor
There was a problem hiding this comment.
should allow GUIDED for quadplanes, but only if ground speed below 2m/s when tune starts
should also have a list of modes for copters
need to check the builtin C++ implementation to ensure it restricts modes
… Plane 4.6+ Adds a note at the top of the applet's README pointing Plane users at the built-in AP_Quicktune library that has shipped since Plane 4.6.0 (May 2025). The Lua applet remains the only option for Copter and for users on older Plane firmware. Signed-off-by: Roger O'Neill <rwoneill@users.noreply.github.com>
Contributor
|
I've found that the method get_mav_vtol_state() is useful to interpret what a VTOL is doing (fixed wing vs transition vs VTOL flight). If you add a binding for it to bindings.desc, you can use this in this Lua script which might be helpful. You can add this line to bindings.desc to make this available in Lua:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refuse to tune in
VTOL-quicktune.luaunless the quadplane is in QSTABILIZE / QHOVER / QLOITER, and add a note in the applet README pointing Plane users at the built-inAP_Quicktunelibrary (shipping in Plane since 4.6.0).Classification & Testing (check all that apply and add your own)
SITL test plan run against this branch on
arduplane --model quadplane,--speedup 20, scripting on,RC7_OPTION=300,QUIK_RC_FUNC=300,QUIK_DOUBLE_TIME=5. Test harness drives everything via pymavlink (mode set, force-arm, RC overrides, param polls).Tuning: requires QSTABILIZE/QHOVER/QLOITERrepeats,Q_A_RAT_RLL_Dstays at baseline.VTOL airbrake → position1 → position2 → Land descend.RLL_D → RLL_P → PIT_D → PIT_P → YAW_Dramp/done sequence. Behavior identical to unpatched script in the supported mode.Tuning: revertedand gains returned to baseline. Existing abort path fires correctly via the newnot in_tunable_modeclause.(not is_quadplane) → in_tunable_mode = true, so behavior is byte-identical for Copter; would still be good to confirm.)Description
Bug
VTOL-quicktune.luaonly gates onarming:is_armed()andvehicle:get_likely_flying(). Both are true during fixed-wing flight on a quadplane.The "oscillation done" check uses
AC_AttitudeControl:get_rpy_srate(). On a quadplane in fixed-wing flight, the VTOL attitude/rate controllers are not actively producing motor outputs, so the slew rate stays near zero. Withsrate < QUIK_OSC_SMAXalways, the gain doubles everyQUIK_DOUBLE_TIMEseconds (default 10 s) without ever satisfying the "done" condition.QUIK_ANGLE_MAX(PR #28890) doesn't help either — same reason: the VTOL controller isn't running, so attitude error from its perspective stays at zero.If the tune-position switch is bumped during a fixed-wing leg,
Q_A_RAT_*_Dramps unbounded; on the transition back to VTOL the inflated gains drive the controller unstable.Motivation
A pilot accidentally toggled the quicktune script during an RTL leg, which caused a progressive loss of control through the landing phase. The script ramped gains throughout the fixed-wing return; on the transition back to VTOL for landing, the inflated gains drove the aircraft unstable.
Fix (commit 1)
Restrict tuning to QSTABILIZE / QHOVER / QLOITER only — the pilot-controlled VTOL hover modes the applet's documentation was written for:
QLAND,QRTL— pilot can't intervene cleanly),QAUTOTUNE(conflicts), andQACRO(rate-control intent collides with tune-induced motion). If the pilot transitions out of a tunable mode mid-tune, gains revert via the existing abort path (same behavior as disarming or moving the switch low).Mode::supports_quicktune()totruein ArduPlane/mode.h — QSTABILIZE, QHOVER, QLOITER. Convergent evidence that this gate set is the right one.Doc note (commit 2)
Adds a note to
libraries/AP_Scripting/applets/VTOL-quicktune.mdpointing Plane users at the built-inAP_Quicktunelibrary, which has shipped in ArduPlane since 4.6.0 (May 2025). The Lua applet remains the only quicktune option for Copter (native quicktune is enabled only withHAL_QUADPLANE_ENABLED) and for users on older Plane firmware.Suggested follow-up (separate PR to ardupilot_wiki)
The Plane wiki page https://ardupilot.org/plane/docs/quicktune.html documents the built-in version (parameters
QWIK_*, aux function181) but does not mention the Lua applet at all. A user withVTOL-quicktune.luaalready on their SD card from a pre-4.6 setup has no easy way to tell that they're running a different code path (QUIK_*params, aux function300). A short note on that wiki page calling out the distinction would close the loop. Happy to open a PR againstArduPilot/ardupilot_wikiif that's useful.