Skip to content

Plane: finalize throttle before tiltrotor output - #34839

Open
Hwurzburg wants to merge 2 commits into
ArduPilot:masterfrom
Hwurzburg:plane-tiltrotor-final-throttle-output
Open

Hwurzburg wants to merge 2 commits into
ArduPilot:masterfrom
Hwurzburg:plane-tiltrotor-final-throttle-output

Conversation

@Hwurzburg

@Hwurzburg Hwurzburg commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Finalize Plane's forward throttle output before the tiltrotor consumes it, so tilting motors in fixed-wing flight honour the same throttle limits as the normal fixed-wing throttle output.

This is an alternative implementation to #34277 and fixes #34274.

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

Tested in SITL at fa476e8e67:

  • Tools/autotest/autotest.py build.Plane
  • Tools/autotest/autotest.py test.QuadPlane.TiltrotorThrottleLimits
  • Tools/autotest/autotest.py test.QuadPlane.TiltrotorBinaryThrottleLimits
  • Tools/autotest/autotest.py test.QuadPlane.TiltrotorICEThrottleLimits
  • Tools/autotest/autotest.py test.QuadPlane.TiltrotorICEIdleThrottle
  • Tools/autotest/autotest.py test.QuadPlane.TiltrotorVectoringRoll
  • Tools/scripts/check_branch_conventions.py --base-branch upstream/master

All passed. The throttle-limit tests set THR_MAX=60, command full pilot throttle in FBWA, and check the mean tilt-motor PWM remains at the configured limit. The binary test explicitly sets Q_TILT_TYPE=1; the quadplane-tilttri model otherwise defaults to continuous tilt.

The two ICE tests use quadplane-tilthvec with ICE_ENABLE=1 and the engine never started. TiltrotorICEThrottleLimits checks the tilt motors still give forward thrust and honour THR_MAX while the ICE override holds the engine throttle at zero. TiltrotorICEIdleThrottle sets ICE_IDLE_PCT=20 and checks the tilt motors follow zero pilot throttle, not the engine idle.

Description

Plane::set_servos() currently calls quadplane.update() before set_throttle(). quadplane.update() calls tiltrotor.update(), which reads k_throttle and immediately writes the tilting motors through output_motor_mask(). In manual-throttle fixed-wing modes this happens before set_throttle() applies battery compensation, throttle limits and suppression, so the direct motor output can bypass THR_MAX even though the subsequently limited throttle channel and CTUN.ThO look correct.

Difference from #34277

#34277 leaves the tiltrotor output in its current position, splits throttle-limit calculation from application, caches the calculated limits, and applies the previous loop's cached values at the tiltrotor reads.

This PR changes the ordering instead:

  1. quadplane.update() updates transition state and, in VTOL modes, writes the forward-throttle demand.
  2. set_throttle() performs the existing battery compensation, min/max limiting, watt limiting, reverse-thrust gating and suppression without modification.
  3. throttle_slew_limit() applies the existing slew limit.
  4. tiltrotor.update() consumes that finalized current-loop throttle and writes the tilt-motor output.
  5. The disarmed throttle outputs and the ICE throttle_override() are applied to the engine throttle channel, then servos_output() writes the remaining outputs.

This avoids a second throttle-limit application path, cached state, invalid-cache fallbacks and a one-loop stale-limit window. The existing limit calculation remains in its original location, so the watt limiter, forward battery compensation and TECS limit setters keep their current ordering and inputs. THR_PASS_STAB also retains its existing behaviour because the tiltrotor consumes whatever the normal Plane throttle pipeline produces.

tiltrotor.update() deliberately runs before the disarmed and ICE overrides. Those overrides only apply to the engine throttle output. While the engine is not running, the ICE override holds that output at zero (or ICE_START_PCT while cranking), which would otherwise remove all tilt-motor forward thrust.

ICE idle throttle

apply_throttle_limits() now only adds the ICE idle throttle (ICE_IDLE_PCT or the RPM idle governor) to the minimum throttle while the engine is in the running state. When the engine is not running, the ICE override replaces the engine throttle anyway, and the idle minimum would otherwise drive the electric tilt motors with zero throttle demand. It also stops TECS from assuming idle thrust from a stopped engine.

While the engine is running, the tilt motors follow the same limited throttle as the engine, including the idle floor. This is intentional: the tilt motors honour every fixed-wing throttle limit, THR_MIN included, and the ICE idle is part of that limit set, which TECS also plans with.

Motor test

Moving the call outside quadplane.update() would otherwise make it run during a motor test, where quadplane.update() currently returns early. A motor-test early return in tiltrotor.update() preserves that behaviour, so the now-redundant motor-test check in continuous_update() is removed. The check in bicopter_output() stays.

The regression tests cover both continuous/vectored and actual binary tiltrotor output paths. The existing vectoring-roll test is also run to check that moving the update later in set_servos() does not change tilt-vectoring direction.

AI assistance

This contribution was AI-assisted.

@AP-Review

AP-Review commented Oct 21, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-10-21)

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

Reviewed at head 3f2c92b812.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/ardupilot/34839/1.html#pr34839

The tilt update now uses the final throttle, so the THR_MAX fix works and the new tests fail on master as they should, but the move also places the tilt update after the ICE throttle override.

Blocking

  1. ArduPlane/servos.cpp:972: quadplane.tiltrotor.update() runs after the AP_ICENGINE throttle_override(), so the electric tilt motors get the engine-only throttle (0 while the engine is not running, ICE_START_PCT while starting). In SITL, quadplane-tilthvec with ICE_ENABLE=1 and the engine not started never transitions in FBWA at full stick (about 1740 PWM, under 2 m/s airspeed); master reaches 49.5 m/s. Calling it right after throttle_slew_limit(), before the ICE block, matches master on that case and both new tests still pass.
Minor (1)
  • ArduPlane/tiltrotor.cpp:387: with this early return, the !quadplane.motor_test.running check around output_motor_mask() in continuous_update() (tiltrotor.cpp:246) is always true and can be removed. Keep the check in bicopter_output().

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Global Size Summary (Total Flash delta in bytes)

Built from fa476e8 rebased onto 3d24375

Board Periph tracker blimp bootloader copter heli iofw plane rover sub
DrotekP3Pro _ _ _ * _ _ _ _ _ _
Durandal _ * * _ * * _ +16 * *
Hitec-Airspeed * _ _ _ _ _ _ _ _ _
KakuteF7 _ * * _ * * _ -8 * *
MambaH743v4 _ * * _ * * _ +4 * *
MatekF405-CAN _ _ _ * _ _ _ _ _ _
MatekF405 _ * * _ * * _ -8 * *
MatekH743-bdshot _ * * _ * * _ +20 * *
Pixhawk1-1M _ * * _ * * _ -4 * *
disco _ * * _ * * _ +12 * *
f103-GPS * _ _ _ _ _ _ _ _ _

@Hwurzburg
Hwurzburg force-pushed the plane-tiltrotor-final-throttle-output branch from 3f2c92b to 96b663d Compare October 22, 2026 12:33
@AP-Review

AP-Review commented Oct 22, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-10-22)

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

Reviewed at head 96b663d937.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/ardupilot/34839/2.html#pr34839

The tiltrotor THR_MAX fix looks good at 96b663d, with one small PR-description update suggested.

Since the last review, the tilt update was moved before the disarmed and ICE throttle overrides (ArduPlane/servos.cpp:930), the redundant motor-test check was removed, and the new TiltrotorICEThrottleLimits test fails on the previous head and passes now.

Minor (1)
  • PR description: add TiltrotorICEThrottleLimits to the testing list, and note that tiltrotor.update() deliberately runs before the disarmed/ICE throttle overrides.

Run the tiltrotor output update after Plane has completed its normal throttle processing. This makes direct tilt-motor forward thrust consume the same battery-compensated, limited and suppressed throttle value as the fixed-wing throttle output without caching limits or adding a tiltrotor-specific limiter.

Update the tiltrotor before the disarmed throttle outputs and the ICE engine throttle override. Those only apply to the fixed-wing throttle output, and the ICE override holds it at zero while the engine is not running, which would remove tilt-motor forward thrust.

Only apply the ICE idle throttle as a minimum throttle limit while the engine is running. When it is not running the ICE override replaces the engine's throttle anyway, and the idle minimum would otherwise drive the electric tilt motors with zero throttle demand. This also stops TECS from assuming idle thrust from a stopped engine.

Keep tiltrotor updates disabled during motor tests, matching the previous early return from QuadPlane::update(). This makes the motor test check in continuous_update() redundant, so remove it.
Exercise continuous and binary tiltrotors in FBWA with full pilot throttle and THR_MAX set to 60 percent. Check the mean tilt-motor PWM remains at the configured limit while allowing differential rudder output to cancel in the average.

Set Q_TILT_TYPE explicitly for the binary case because the tilt-tricopter model defaults to continuous tilt.

Repeat the vectored case with ICE_ENABLE set and the engine never started, so the ICE throttle override holds the fixed-wing throttle at zero. The tilt motors must still provide forward thrust and honour THR_MAX.

Also check that with ICE_IDLE_PCT set and the engine never started, the tilt motors follow zero pilot throttle rather than the engine idle throttle.
@Hwurzburg
Hwurzburg force-pushed the plane-tiltrotor-final-throttle-output branch from 96b663d to fa476e8 Compare October 22, 2026 13:59
@AP-Review

Copy link
Copy Markdown

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

Reviewed at head fa476e8e67.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/ardupilot/34839/3.html#pr34839

The tiltrotor THR_MAX fix still works at fa476e8; one new minor behaviour question and the description update remain.

Since the last review, the ICE idle floor is now applied only while the engine is running, and the new TiltrotorICEIdleThrottle test passes at head and fails on the previous head.

Minor

  • ArduPlane/servos.cpp:935: with the engine running, the ICE idle floor from apply_throttle_limits() (servos.cpp:546) now also drives the electric tilt motors in FBWA-style modes. At minimum stick they hold ICE_IDLE_PCT (1200 PWM in SITL with 20%), where master gives 1000. Please confirm this is intended, or keep the idle floor out of the tilt-motor throttle.
  • PR description (still open): add TiltrotorICEThrottleLimits and TiltrotorICEIdleThrottle to the testing list, and mention the ICE_RUNNING gate and that tiltrotor.update() runs before the disarmed/ICE overrides.

Not fully reviewed: CI at fa476e8 was still running (plane-tests1b, Durandal, linux base); the RPM idle governor and in-flight engine stop/restart were not exercised.

@Hwurzburg

Copy link
Copy Markdown
Contributor Author

Re the ICE idle floor on the tilt motors with the engine running: that is intended. The tilt motors now follow every fixed-wing throttle limit, THR_MIN included, and the ICE idle is part of that limit set, which TECS also plans with. Keeping it off the tilt-motor output only would mean either changing the TECS limits for every ICE plane or carrying a second minimum through the takeoff/flare/battery compensation/watt limit chain. PR description updated with the ICE tests, the ICE_RUNNING gate and the override ordering.

@IamPete1

IamPete1 commented Nov 3, 2026

Copy link
Copy Markdown
Member

This is still on my list, changing the ordering of operations likes this makes me very nervous. I plan to tidy up how we do throttle outputs (#34351 is part of that) in the hope that we can do a smaller re-order that is more clearly correct.

The bug that this addresses has been in tiltrotor forever as far as I can tell so I don't think we need to rush out a fix, but I would like to fix this before the 4.8

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.

Plane: tiltrotor forward-thrust motors bypass THR_MAX/THR_MIN/THR_SLEWRATE in manual-throttle modes

4 participants