From 6d2620a4182ffdfef5b3ec4f841895d9cc81f5dc Mon Sep 17 00:00:00 2001 From: Yang Hau Date: Sun, 1 Nov 2026 05:05:13 +0800 Subject: [PATCH] fix(mavlink): reject SET_ATTITUDE_TARGET with a non-finite thrust (#29328) A NaN thrust setpoint means "stop the motors on that axis" to the control allocator. SET_ATTITUDE_TARGET validated the attitude but passed thrust through unchecked, so a companion sending a NaN thrust stopped all lift motors of a multicopter in Offboard, while the message kept the offboard heartbeat alive so the offboard loss failsafe never triggered. Drop the whole message, as is already done for an unusable attitude. Tested in SIH: streaming SET_ATTITUDE_TARGET with a NaN thrust in Offboard no longer produces a non-finite vehicle_thrust_setpoint; the offboard loss failsafe takes over and the vehicle holds altitude. --- src/modules/mavlink/mavlink_receiver.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/modules/mavlink/mavlink_receiver.cpp b/src/modules/mavlink/mavlink_receiver.cpp index da9fa0180f6..da9339a5a91 100644 --- a/src/modules/mavlink/mavlink_receiver.cpp +++ b/src/modules/mavlink/mavlink_receiver.cpp @@ -1887,6 +1887,13 @@ MavlinkReceiver::handle_message_set_attitude_target(mavlink_message_t *msg) return; } + // A non-finite thrust setpoint stops the motors on that axis (see VehicleThrustSetpoint.msg), so drop the + // whole message for the same reason as an unusable attitude. + if ((thrust_body && !matrix::Vector3f(attitude_target.thrust_body).isAllFinite()) + || (!thrust_body && thrust && !PX4_ISFINITE(attitude_target.thrust))) { + return; + } + vehicle_status_s vehicle_status{}; _vehicle_status_sub.copy(&vehicle_status);