From d0349fcf07c4bd23220320fe5d3e6a5383515ad4 Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Mon, 9 Mar 2020 11:23:30 +0100 Subject: [PATCH] mc_pos_control: allow zero thrust during takeoff and landing Otherwise the takeoff ramp doesn't start with zero thrust and the land thrust cut cannot cut to zero. --- src/modules/mc_pos_control/mc_pos_control_main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/modules/mc_pos_control/mc_pos_control_main.cpp b/src/modules/mc_pos_control/mc_pos_control_main.cpp index 4b5d0ef05d..8aa4f2d8fc 100644 --- a/src/modules/mc_pos_control/mc_pos_control_main.cpp +++ b/src/modules/mc_pos_control/mc_pos_control_main.cpp @@ -612,6 +612,14 @@ MulticopterPositionControl::Run() const bool flying = _takeoff.getTakeoffState() >= TakeoffState::flight; const bool flying_but_ground_contact = flying && _vehicle_land_detected.ground_contact; + if (flying) { + _control.setThrustLimits(_param_mpc_thr_min.get(), _param_mpc_thr_max.get()); + + } else { + // allow zero thrust when taking off and landing + _control.setThrustLimits(0.f, _param_mpc_thr_max.get()); + } + if (not_taken_off || flying_but_ground_contact) { // we are not flying yet and need to avoid any corrections reset_setpoint_to_nan(setpoint);