From e80c008909f779ca5471c99c19e4806a22f95190 Mon Sep 17 00:00:00 2001 From: Ted <86834177+TedObrien@users.noreply.github.com> Date: Mon, 12 Oct 2026 00:44:35 +0100 Subject: [PATCH] fix(PositionControl): Prevent vehicle flipping on landing if MPC_ACC_DECOUPLE disabled (#27279) * fix(PositionControl): create ground contact flag that prevents the z_specific_force being added to the z acceleration setpoint during landing. * fix(PositionControl): Combine setGroundContact with decoupleHorizontalAndVecticalAcceleration * docs(mc_pos_control): explain why decoupling is forced on the ground The PositionControl comment described a ground-contact exception that only the caller makes, and the caller's comment said what the line does rather than why it must match the idle setpoint condition. Assisted-by: Claude:claude-opus-5-5 --------- Co-authored-by: Jacob Dahl --- src/modules/mc_pos_control/MulticopterPositionControl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/mc_pos_control/MulticopterPositionControl.cpp b/src/modules/mc_pos_control/MulticopterPositionControl.cpp index 245f646f1ba..3c148742a4b 100644 --- a/src/modules/mc_pos_control/MulticopterPositionControl.cpp +++ b/src/modules/mc_pos_control/MulticopterPositionControl.cpp @@ -195,7 +195,6 @@ void MulticopterPositionControl::parameters_update(bool force) Vector3f(_param_mpc_xy_vel_i_acc.get(), _param_mpc_xy_vel_i_acc.get(), _param_mpc_z_vel_i_acc.get()), Vector3f(_param_mpc_xy_vel_d_acc.get(), _param_mpc_xy_vel_d_acc.get(), _param_mpc_z_vel_d_acc.get())); _control.setHorizontalThrustMargin(_param_mpc_thr_xy_marg.get()); - _control.decoupleHorizontalAndVecticalAcceleration(_param_mpc_acc_decouple.get()); _goto_control.setParamMpcAccHor(_param_mpc_acc_hor.get()); _goto_control.setParamMpcAccDownMax(_param_mpc_acc_down_max.get()); _goto_control.setParamMpcAccUpMax(_param_mpc_acc_up_max.get()); @@ -497,6 +496,10 @@ void MulticopterPositionControl::Run() const bool flying = (_takeoff.getTakeoffState() >= TakeoffState::flight); const bool flying_but_ground_contact = (flying && _vehicle_land_detected.ground_contact); + // Same condition as the [0, 0, 100] idle setpoint below: coupled, it points body_z down + // and limitTilt commands full tilt + _control.decoupleHorizontalAndVecticalAcceleration(_param_mpc_acc_decouple.get() || not_taken_off || flying_but_ground_contact); + if (!flying) { _control.setHoverThrust(_param_mpc_thr_hover.get()); }