From 5f5a2d11efb5833bb7a9e5f67ad180f19ab5c853 Mon Sep 17 00:00:00 2001 From: Ahmet Burak Tektas <15087318+Abtektas@users.noreply.github.com> Date: Fri, 30 Oct 2026 22:47:45 +0100 Subject: [PATCH] fix(fw_mode_manager): ignore setpoints from before Offboard (#29279) (#29465) Run() chose the setpoint source with the control mode of the previous cycle, because vehicle_control_mode_poll() ran after that choice, and on entering Offboard it still held the last setpoint read, for example the one from Offboard as a multicopter before the transition (NaN position, finite velocity, marked valid). The first fixed-wing Offboard cycles followed that setpoint until a new trajectory_setpoint arrived. Poll the control mode before choosing the setpoint source, and mark the current setpoint invalid when Offboard starts. Assisted-by: Claude:claude-opus-5-5 (cherry picked from commit 77aaa2f6da311e05a3bb455841b68aa0948cdf7c) Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com> --- src/modules/fw_mode_manager/FixedWingModeManager.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/fw_mode_manager/FixedWingModeManager.cpp b/src/modules/fw_mode_manager/FixedWingModeManager.cpp index 560292ec3a7..d8b28e01e46 100644 --- a/src/modules/fw_mode_manager/FixedWingModeManager.cpp +++ b/src/modules/fw_mode_manager/FixedWingModeManager.cpp @@ -111,6 +111,7 @@ FixedWingModeManager::vehicle_control_mode_poll() { if (_control_mode_sub.updated()) { const bool was_armed = _control_mode.flag_armed; + const bool was_offboard = _control_mode.flag_control_offboard_enabled; if (_control_mode_sub.copy(&_control_mode)) { @@ -119,6 +120,11 @@ FixedWingModeManager::vehicle_control_mode_poll() reset_takeoff_state(); reset_landing_state(); } + + // only follow setpoints received in this Offboard session, not what an earlier mode left behind + if (!was_offboard && _control_mode.flag_control_offboard_enabled) { + _position_setpoint_current_valid = false; + } } } } @@ -2118,6 +2124,9 @@ FixedWingModeManager::Run() _go_direct_to_destination = true; } + // the control mode decides below where the setpoint is taken from, so it has to be current + vehicle_control_mode_poll(); + if (_control_mode.flag_control_offboard_enabled) { trajectory_setpoint_s trajectory_setpoint; @@ -2215,7 +2224,6 @@ FixedWingModeManager::Run() vehicle_attitude_poll(); vehicle_attitude_setpoint_poll(); vehicle_command_poll(); - vehicle_control_mode_poll(); wind_poll(now); if (_vehicle_land_detected_sub.updated()) {