From 0f78cd65a0bc7a0fc01ad730d909c49587549931 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 16 Jul 2026 08:52:49 +1200 Subject: [PATCH] test(mavsdk): retry arming to tolerate transient is_armable flicker wait_until_ready() polls MAVSDK's is_armable, but a known hysteresis gap (and estimator heading-reference flicker at startup) means the flag can read armable while PX4 then denies the arm command with 'no heading reference'. This made arm() fail intermittently. Retry the arm command until the autopilot accepts it, so the transient is absorbed while real failures still time out. Signed-off-by: Julian Oes --- test/mavsdk_tests/autopilot_tester.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/mavsdk_tests/autopilot_tester.cpp b/test/mavsdk_tests/autopilot_tester.cpp index 8755e508592..52a20deb7b3 100644 --- a/test/mavsdk_tests/autopilot_tester.cpp +++ b/test/mavsdk_tests/autopilot_tester.cpp @@ -185,8 +185,12 @@ void AutopilotTester::set_param_vt_fwd_thrust_en(int value) void AutopilotTester::arm() { - const auto result = _action->arm(); - REQUIRE(result == Action::Result::Success); + // Even after wait_until_ready() passes, the is_armable health flag can + // transiently flicker (e.g. the estimator's heading reference briefly + // dropping out during startup), causing the arm command to be denied. + // Retry until the autopilot actually accepts it. + REQUIRE(poll_condition_with_timeout( + [this]() { return _action->arm() == Action::Result::Success; }, std::chrono::seconds(30))); } void AutopilotTester::takeoff()