fix(tecs): assume gliding in the pitch loop without a throttle range

At speed weight 2 the pitch flies airspeed only and its climb angle follows
from the total energy rate. With the setpoint's rate it pitched towards the
altitude demand, which a glider has no throttle to deliver, so it held the
airspeed only once the integrator had given the demand up. With no throttle
range (FW_THR_MAX = FW_THR_MIN, also a gliding waypoint) the pitch now takes
the minimum total energy rate, the glide, as fast descend and underspeed
already do.

Limited to speed weight 2: below it the throttle range also closes at the
end of the landing flare, where the pitch keeps flying the height rate
setpoint.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RomanBapst <bapstroman@gmail.com>
This commit is contained in:
RomanBapst authored and GitHub committed 2026-11-27 10:16:17 +03:00
1 parent 6daedeb36d
commit 7ab904457c
3 files changed
+19 -9

No files matched your search

@@ -197,6 +197,7 @@ With an airspeed setpoint at or below trim there is no middle region, and pitch
These regions apply up to a speed weight of 1 and are faded out as the speed weight goes from 1 to 2, so with a weight of 2 pitch alone tracks the full airspeed setpoint.
Gliders, which have no throttle to accelerate with, should therefore use `FW_T_SPDWEIGHT` = 2.
Gliders should also set [FW_THR_MAX](../advanced_config/parameter_reference.md#FW_THR_MAX) equal to [FW_THR_MIN](../advanced_config/parameter_reference.md#FW_THR_MIN): with a speed weight of 2 and no throttle range, pitch assumes the vehicle glides at the minimum sink rate ([FW_T_SINK_MIN](../advanced_config/parameter_reference.md#FW_T_SINK_MIN)) instead of flying the climb or descent rate demanded by the altitude setpoint.
The speed weight is also raised towards 2 automatically during underspeed recovery and fast descend, which therefore still use pitch to reach their airspeed setpoint.
## Fixed-Wing Attitude Controller
+12 -1
View File
@@ -580,7 +580,18 @@ float TECSControl::_calcPitchControlSteRate(const STERateLimit &limit,
// on the maximum throttle it commands (failed engine, throttle still slewing up, less excess power near stall).
// Assume gliding, the minimum total energy rate, in both. If the throttle does deliver in underspeed, the
// airspeed recovers faster.
return lerp(ste_rate_pair, limit.STE_rate_min, constrain(max(param.fast_descend, _ratio_undersped), 0.f, 1.f));
float gliding_ratio = constrain(max(param.fast_descend, _ratio_undersped), 0.f, 1.f);
// A glider (speed weight 2 with no throttle range, also a gliding waypoint) has no throttle to deliver the
// setpoint's total energy rate at all: it always glides. Not applied below speed weight 2, where the throttle
// range also closes at the end of the landing flare and the pitch keeps flying the height rate setpoint.
const bool no_throttle_range = param.throttle_max - param.throttle_min < FLT_EPSILON;
if (no_throttle_range && param.pitch_speed_weight > 2.f - FLT_EPSILON) {
gliding_ratio = 1.f;
}
return lerp(ste_rate_pair, limit.STE_rate_min, gliding_ratio);
}
float TECSControl::_calcPitchControlOutput(const Input &input, const ControlValues &seb_rate, float ste_rate_setpoint,
+6 -8
View File
@@ -541,18 +541,16 @@ TEST_F(TECSControlClosedLoopTest, AltitudeStepUpDefaultTuningPitchOffset)
// --- Gliding at speed weight 2 ---------------------------------------------------
//
// Speed weight 2 is the glider setting: the pitch flies airspeed only, so it tracks an airspeed setpoint with no
// propulsion at all.
//
// Disabled: at speed weight 2 the climb angle follows entirely from the total energy rate the throttle delivers,
// gamma = (SEB rate + 2 STE rate) / (2 g V). The pitch takes it from the setpoint, which with a failed throttle is
// never delivered, so the pitch flies the altitude demand. Needs the pitch to assume gliding at speed weight 2.
// propulsion at all. A glider has no throttle range (throttle max = min). Its climb angle follows from the total energy
// rate, gamma = (SEB rate + 2 STE rate) / (2 g V), which the pitch must take as the glide (minimum total energy rate),
// not the altitude demand of the setpoint, which no throttle delivers.
TEST_F(TECSControlClosedLoopTest, DISABLED_GlideSpeedWeightTwoAirspeedStep)
TEST_F(TECSControlClosedLoopTest, GlideSpeedWeightTwoAirspeedStep)
{
_params.pitch_speed_weight = 2.f;
_params.throttle_max = _params.throttle_min;
_throttle = _params.throttle_min;
run(10.f);
_throttle_failed = true;
run(60.f); // settle into the glide
setAirspeedSetpoint(_params.equivalent_airspeed_trim + AIRSPEED_STEP);