From 77aaa2f6da311e05a3bb455841b68aa0948cdf7c Mon Sep 17 00:00:00 2001 From: Ahmet Burak Tektas <15087318+Abtektas@users.noreply.github.com> Date: Tue, 27 Oct 2026 13:25:32 +0100 Subject: [PATCH] fix(fw_mode_manager): ignore setpoints from before Offboard (#29279) 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 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 9f516c25aad..62cd9f4c438 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; + } } } } @@ -2191,6 +2197,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; @@ -2289,7 +2298,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()) {