From edfcdaa0089b437d4d7e1089568c9ba535c4386d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 19 Aug 2025 15:48:25 +0200 Subject: [PATCH] commander: check for stale arming_check_reply messages based on the message timestamp. Previously it was possible to run into the following case: - 2 external modes are registered (running inside the same ROS node) - they time out due to the micro xrce agent being blocked for some reason - PX4 removes them - the latest arming check replies still arrive to PX4 - the application restarts - the first mode gets registered - PX4 handles the previous arming check reply, and clears waiting_for_first_response, which reduces the timeout - the second mode registers and as part of that checks for message compatibility. This takes ~1s, triggering a timeout of the first mode --- .../HealthAndArmingChecks/checks/externalChecks.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/commander/HealthAndArmingChecks/checks/externalChecks.cpp b/src/modules/commander/HealthAndArmingChecks/checks/externalChecks.cpp index b1f2abc064..80a92b067c 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/externalChecks.cpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/externalChecks.cpp @@ -229,8 +229,10 @@ void ExternalChecks::update() int max_num_updates = arming_check_reply_s::ORB_QUEUE_LENGTH; while (_arming_check_reply_sub.update(&reply) && --max_num_updates >= 0) { - if (reply.registration_id < MAX_NUM_REGISTRATIONS && registrationValid(reply.registration_id) - && _current_request_id == reply.request_id) { + const bool valid = reply.registration_id < MAX_NUM_REGISTRATIONS && registrationValid(reply.registration_id); + const bool timed_out = now > reply.timestamp + 300_ms; + + if (!timed_out && valid && _current_request_id == reply.request_id) { _reply_received_mask |= 1u << reply.registration_id; _registrations[reply.registration_id].num_no_response = 0; _registrations[reply.registration_id].waiting_for_first_response = false;