test(mavsdk_tests): specify the pusher failure detection in fixed-wing flight

The spec now covers a pusher that fails on a fixed-wing leg, with and
without headwind, a working pusher flying fixed-wing legs above the
check's throttle threshold, and the former gap of a pusher failing late in
an airspeed-less transition, which the fixed-wing check now reports. The
flights simulate the battery current with SIM_BAT_I_MOT.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: jonas <jonspero@me.com>
This commit is contained in:
jonas committed 2026-11-20 11:31:22 +01:00
1 parent d9879734b9
commit 9d07cc2571
2 files changed
+108 -22

No files matched your search

@@ -103,10 +103,16 @@ class AutopilotTesterPusherFailure(AutopilotTester):
"""Turn weathervane off, so the nose stays north and the wind a head- or tailwind."""
self.set_param_int("WV_EN", 0)
def start_multicopter_mission(self, waypoints: List[Tuple[float, float]],
altitude_m: float) -> None:
"""Fly to each (north, east) waypoint relative to home in multicopter mode and land at
the last one."""
def enable_fixed_wing_propulsion_check(self, motor_current_max_a: float,
propulsion_current_min_a: float) -> None:
"""Simulate the ESC and battery current (SIM_BAT_I_MOT) and enable the fixed-wing
propulsion failure check (COM_EF_CURR)."""
self.set_param_float("SIM_BAT_I_MOT", motor_current_max_a)
self.set_param_float("COM_EF_CURR", propulsion_current_min_a)
def start_mission(self, waypoints: List[Tuple[float, float]], altitude_m: float) -> None:
"""Fly to each (north, east) waypoint relative to home, in the current VTOL mode, and land
at the last one."""
ct = self.get_coordinate_transformation()
def item(seq: int, command: int, north_m: float, east_m: float, z: float) -> Any:
@@ -144,6 +150,22 @@ class AutopilotTesterPusherFailure(AutopilotTester):
log("Pusher stopped")
return self._pusher_failure_time_s
def pusher_failure_time_s(self) -> float:
assert self._pusher_failure_time_s is not None, "fail_pusher() was not called"
return self._pusher_failure_time_s
def check_pusher_output_above(self, output: float, duration_s: float) -> None:
"""Check that the pusher output stays at least this high for this time, after it got
there."""
assert self.poll_condition_with_timeout(lambda: self._pusher_output() >= output, 10), \
"Pusher output {:.0f}, expected at least {:.0f}".format(self._pusher_output(), output)
end_s = self.time_s() + duration_s
while self.time_s() < end_s:
current_output = self._pusher_output()
assert current_output >= output, \
"Pusher output {:.0f}, expected at least {:.0f}".format(current_output, output)
self.sleep_for(0.1)
def check_pusher_stopped(self) -> None:
"""Check that the injected failure cut the pusher output while it should push."""
assert self.poll_condition_with_timeout(
+82 -18
View File
@@ -1,4 +1,4 @@
"""Pusher failure detection of standard VTOLs (VT_EF_TIME, VT_EF_FT_ACC).
"""Pusher failure detection of standard VTOLs (VT_EF_TIME, VT_EF_FT_ACC, COM_EF_CURR).
What the detection must achieve, whatever the detector:
1. A pusher that failed before or early in a front transition triggers the pusher failure
@@ -7,14 +7,19 @@ What the detection must achieve, whatever the detector:
2. A pusher that fails while the vehicle flies forward with pusher assist (VT_FWD_THRUST_EN) in
multicopter mode triggers the pusher failure quad-chute within DETECTION_TIME_S. The vehicle
then stays in multicopter mode and lands.
3. A working pusher triggers no quad-chute, in multicopter flight and in front transitions.
3. A working pusher triggers no quad-chute, in multicopter flight, in front transitions and in
fixed-wing flight.
4. With a battery current measurement, a pusher that fails in fixed-wing flight triggers the pusher
failure quad-chute within FW_DETECTION_TIME_S, with or without airspeed sensor. The vehicle
then flies in multicopter mode and lands.
Accepted, not required: a headwind stronger than the pusher may be reported as a pusher failure,
since the vehicle cannot make progress with pusher assist anyway.
Known gaps of the VT_EF_* detector: a tailwind that carries the vehicle within VT_EF_VEL_ERR of
its velocity setpoint hides the failure, a pusher that fails in hover is only detected on the
next pusher-assisted leg or at the start of the next front transition, and a pusher that fails
after the transition check passed (about 3.4 s into the transition) is not detected.
after the transition check passed (about 3.4 s into the transition) is only detected once in
fixed-wing flight, with COM_EF_CURR set and a battery current measurement.
The detection times are logged, so detectors can be compared with the same flights:
test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 10 --model standard_vtol \\
@@ -25,8 +30,7 @@ SIH has constant wind only and a 0.2 kg vehicle, so the flights check behavior,
import pytest
from autopilot_tester_pusher_failure import (PUSHER_QUADCHUTE_EVENT,
AutopilotTesterPusherFailure, FixedWingReached,
Wind)
AutopilotTesterPusherFailure, Wind)
ALTITUDE_M = 20.0
SETTLE_S = 10.0
@@ -34,6 +38,18 @@ DETECTION_TIME_S = 10.0
# A failed pusher has to stop the front transition before the open-loop transition would complete
# without airspeed (VT_F_TR_OL_TM default).
FT_DETECTION_TIME_S = 6.0
# Fixed-wing flight: COM_EF_TIME (5 s default) once the throttle is above COM_EF_THROT (0.5
# default), which SIH cruises above (about 0.6).
FW_DETECTION_TIME_S = 10.0
# High enough to glide while the failure is detected.
FW_ALTITUDE_M = 60.0
# The SIH motors draw 20 A at full output (SIM_BAT_I_MOT), growing with output^1.5. In fixed-wing
# flight the vehicle then draws 0.5 A (SIM_BAT_I_IDLE) with a dead pusher, and 7.6 A at 0.5 throttle
# with a working one: 3 A splits them.
MOTOR_CURRENT_MAX_A = 20.0
PROPULSION_CURRENT_MIN_A = 3.0
# Pusher output at the COM_EF_THROT default.
GATE_OUTPUT = 1500.0
# Front transition backstop, the VT_TRANS_TIMEOUT default. PX4 scales it with air density
# (about 16 s at the CI home altitude), which the 5 s margin below covers.
TRANSITION_TIMEOUT_S = 15.0
@@ -57,7 +73,7 @@ def test_pusher_failure_in_multicopter_cruise(
tester = tester_pusher_failure
tester.take_off_with_pusher_assist(ALTITUDE_M)
tester.set_wind(wind, SETTLE_S)
tester.start_multicopter_mission([(300.0, 0.0)], ALTITUDE_M)
tester.start_mission([(300.0, 0.0)], ALTITUDE_M)
tester.wait_until_north_of(40.0, 60)
tester.check_pusher_pushing()
@@ -83,7 +99,7 @@ def test_working_pusher_in_multicopter_mission(
tester.request_ground_truth()
tester.take_off_with_pusher_assist(ALTITUDE_M)
tester.set_wind(wind, SETTLE_S)
tester.start_multicopter_mission([(100.0, 0.0), (100.0, 60.0), (0.0, 60.0)], ALTITUDE_M)
tester.start_mission([(100.0, 0.0), (100.0, 60.0), (0.0, 60.0)], ALTITUDE_M)
tester.wait_until_north_of(40.0, 60)
tester.check_pusher_pushing()
@@ -151,7 +167,7 @@ def test_front_transition_after_pusher_failure_in_cruise(
forward."""
tester = tester_pusher_failure
tester.take_off_with_pusher_assist(ALTITUDE_M)
tester.start_multicopter_mission([(300.0, 0.0)], ALTITUDE_M)
tester.start_mission([(300.0, 0.0)], ALTITUDE_M)
tester.wait_until_north_of(40.0, 60)
tester.check_pusher_pushing()
tester.fail_pusher()
@@ -183,23 +199,71 @@ def test_front_transition_with_working_pusher(
@pytest.mark.vtol_pusher_failure
@pytest.mark.xfail(
strict=True, raises=FixedWingReached,
reason="the transition check ends once the pusher accelerated the vehicle, so a later failure "
"completes the open-loop transition (VT_F_TR_OL_TM)")
def test_pusher_failure_late_in_front_transition(
tester_pusher_failure: AutopilotTesterPusherFailure) -> None:
"""Known gap: without airspeed, the pusher stops after it accelerated the vehicle, but before
the open-loop transition completes."""
"""Requirement 4: without airspeed, the pusher stops after the transition check passed. Today
the open-loop transition completes, and the fixed-wing check reports the failure."""
tester = tester_pusher_failure
tester.take_off_with_pusher_assist(ALTITUDE_M, use_airspeed=False)
tester.enable_fixed_wing_propulsion_check(MOTOR_CURRENT_MAX_A, PROPULSION_CURRENT_MIN_A)
tester.take_off_with_pusher_assist(FW_ALTITUDE_M, use_airspeed=False)
transition_time_s = tester.start_front_transition()
# The check decides 3.4 s into the transition, at the default VT_PSHER_SLEW.
tester.start_front_transition()
# The transition check decides 3.4 s into the transition, at the default VT_PSHER_SLEW.
tester.sleep_for(5)
tester.fail_pusher()
tester.check_pusher_stopped()
tester.check_never_fixed_wing_since(transition_time_s, FT_DETECTION_TIME_S + 5)
check_fixed_wing_flight_stopped(tester)
@pytest.mark.vtol_pusher_failure
@pytest.mark.parametrize("wind", [NO_WIND, STRONG_WIND], ids=["no_wind", "strong_headwind"])
def test_pusher_failure_in_fixed_wing_flight(
tester_pusher_failure: AutopilotTesterPusherFailure, wind: Wind) -> None:
"""Requirement 4: the pusher stops on a fixed-wing mission leg flown north."""
tester = tester_pusher_failure
tester.enable_fixed_wing_propulsion_check(MOTOR_CURRENT_MAX_A, PROPULSION_CURRENT_MIN_A)
tester.take_off_with_pusher_assist(FW_ALTITUDE_M)
tester.set_wind(wind, SETTLE_S)
tester.start_front_transition()
tester.wait_until_fixedwing(TRANSITION_TIMEOUT_S)
tester.start_mission([(2000.0, 0.0)], FW_ALTITUDE_M)
tester.wait_until_north_of(200.0, 120)
tester.check_pusher_pushing()
tester.fail_pusher()
tester.check_pusher_stopped()
check_fixed_wing_flight_stopped(tester)
@pytest.mark.vtol_pusher_failure
def test_working_pusher_in_fixed_wing_flight(
tester_pusher_failure: AutopilotTesterPusherFailure) -> None:
"""Requirement 3: fixed-wing mission legs, which SIH flies above the check's throttle threshold,
then a landing."""
tester = tester_pusher_failure
tester.request_ground_truth()
tester.enable_fixed_wing_propulsion_check(MOTOR_CURRENT_MAX_A, PROPULSION_CURRENT_MIN_A)
tester.take_off_with_pusher_assist(FW_ALTITUDE_M)
tester.start_front_transition()
tester.wait_until_fixedwing(TRANSITION_TIMEOUT_S)
tester.start_mission([(400.0, 0.0), (400.0, 400.0), (0.0, 400.0)], FW_ALTITUDE_M)
# Cruise, after the descent from the altitude overshoot of the transition lowered the throttle.
tester.wait_until_north_of(200.0, 120)
tester.check_pusher_output_above(GATE_OUTPUT, FW_DETECTION_TIME_S)
tester.wait_until_disarmed(450)
tester.check_no_quadchute()
# A failsafe would have landed elsewhere.
tester.check_mission_land_within(5.0)
def check_fixed_wing_flight_stopped(tester: AutopilotTesterPusherFailure) -> None:
"""The pusher failure quad-chute ends fixed-wing flight in time, and the vehicle lands in
multicopter mode."""
detection_delay_s = tester.wait_for_pusher_quadchute(FW_DETECTION_TIME_S)
tester.wait_until_disarmed(240)
# The state reported right at the quad-chute can still be fixed-wing.
tester.check_only_multicopter_since(tester.pusher_failure_time_s() + detection_delay_s + 1)
def check_front_transition_stopped(tester: AutopilotTesterPusherFailure,