From c55679977ef401c1e2971ffd7273e5f0a11342a7 Mon Sep 17 00:00:00 2001 From: Jacob Dahl <37091262+dakejahl@users.noreply.github.com> Date: Tue, 27 Oct 2026 18:14:56 -0800 Subject: [PATCH] fix(mavlink): ignore DISTANCE_SENSOR on a distance sensor link (#29454) A rangefinder peripheral such as the ARK DIST sends its ranges on a link in distance_sensor mode. The flight controller streams every range it has back on that link, the peripheral's own included, and the peripheral published each one as a second distance_sensor instance, which its DISTANCE_SENSOR stream then sent back out. On the flight controller the peripheral's own range came back a round trip late, and any other rangefinder's range came back labelled as the peripheral. A distance sensor link exists only to send ranges, so ignore the ones it receives. Assisted-by: Claude:claude-opus-5-5 (cherry picked from commit 4464ae66b516f18215b5942a7a737102f9ed501c) --- src/modules/mavlink/mavlink_receiver.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/mavlink/mavlink_receiver.cpp b/src/modules/mavlink/mavlink_receiver.cpp index cc0f9437e16..a322e5ad0f6 100644 --- a/src/modules/mavlink/mavlink_receiver.cpp +++ b/src/modules/mavlink/mavlink_receiver.cpp @@ -214,7 +214,12 @@ MavlinkReceiver::handle_message(mavlink_message_t *msg) break; case MAVLINK_MSG_ID_DISTANCE_SENSOR: - handle_message_distance_sensor(msg); + + // The peer streams its ranges back on this link, ours among them, and the stream would send them out again + if (_mavlink.get_mode() != Mavlink::MAVLINK_MODE::MAVLINK_MODE_DISTANCE_SENSOR) { + handle_message_distance_sensor(msg); + } + break; case MAVLINK_MSG_ID_FOLLOW_TARGET: