From 641383cbfbb2d78c715f9140b0ab64230770328b Mon Sep 17 00:00:00 2001 From: Silvan Fuhrer Date: Wed, 18 Aug 2021 13:23:54 +0200 Subject: [PATCH] VTOL backtransition improvements * vtol_type: only allow positive pitch setpoints during backtransition * vtol params: set default of VT_B_DEC_FF to 0, as for most frames a FF is not necessary * Tiltrotor: fix throttle during first part of back transition * Tiltrotor: only enable all motors in second phase of backtransition (tilting phase) Signed-off-by: Silvan Fuhrer --- src/modules/vtol_att_control/tiltrotor.cpp | 13 ++++++++----- .../vtol_att_control/vtol_att_control_params.c | 4 ++-- src/modules/vtol_att_control/vtol_type.cpp | 6 +++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/modules/vtol_att_control/tiltrotor.cpp b/src/modules/vtol_att_control/tiltrotor.cpp index 8303320e5e..be3d90c086 100644 --- a/src/modules/vtol_att_control/tiltrotor.cpp +++ b/src/modules/vtol_att_control/tiltrotor.cpp @@ -380,8 +380,6 @@ void Tiltrotor::update_transition_state() _v_att_sp->thrust_body[0] = _thrust_transition; } else if (_vtol_schedule.flight_mode == vtol_mode::TRANSITION_BACK) { - // turn on all MC motors - set_all_motor_state(motor_state::ENABLED); // set idle speed for rotary wing mode if (!_flag_idle_mc) { @@ -403,13 +401,18 @@ void Tiltrotor::update_transition_state() _v_att_sp->pitch_body = update_and_get_backtransition_pitch_sp(); } - // while we quickly rotate back the motors keep throttle at idle if (time_since_trans_start < BACKTRANS_THROTTLE_DOWNRAMP_DUR_S) { + // blend throttle from FW value to 0 _mc_throttle_weight = 1.0f; const float target_throttle = 0.0f; - blendThrottleDuringBacktransition(time_since_trans_start, target_throttle); + const float progress = time_since_trans_start / BACKTRANS_THROTTLE_DOWNRAMP_DUR_S; + blendThrottleDuringBacktransition(progress, target_throttle); } else if (time_since_trans_start < timeUntilMotorsAreUp()) { + // while we quickly rotate back the motors keep throttle at idle + + // turn on all MC motors + set_all_motor_state(motor_state::ENABLED); _mc_throttle_weight = 0.0f; _mc_roll_weight = 0.0f; _mc_pitch_weight = 0.0f; @@ -511,7 +514,7 @@ void Tiltrotor::blendThrottleAfterFrontTransition(float scale) void Tiltrotor::blendThrottleDuringBacktransition(float scale, float target_throttle) { - _v_att_sp->thrust_body[2] = -(scale * target_throttle + (1.0f - scale) * _last_thr_in_fw_mode); + _thrust_transition = -(scale * target_throttle + (1.0f - scale) * _last_thr_in_fw_mode); } diff --git a/src/modules/vtol_att_control/vtol_att_control_params.c b/src/modules/vtol_att_control/vtol_att_control_params.c index 772faa4e80..3859886fe9 100644 --- a/src/modules/vtol_att_control/vtol_att_control_params.c +++ b/src/modules/vtol_att_control/vtol_att_control_params.c @@ -329,10 +329,10 @@ PARAM_DEFINE_FLOAT(VT_FW_DIFTHR_SC, 0.1f); * @min 0 * @max 0.2 * @decimal 1 - * @increment 0.05 + * @increment 0.01 * @group VTOL Attitude Control */ -PARAM_DEFINE_FLOAT(VT_B_DEC_FF, 0.12f); +PARAM_DEFINE_FLOAT(VT_B_DEC_FF, 0.f); /** * Backtransition deceleration setpoint to pitch I gain. diff --git a/src/modules/vtol_att_control/vtol_type.cpp b/src/modules/vtol_att_control/vtol_type.cpp index 0aa3700a22..0b32d0d828 100644 --- a/src/modules/vtol_att_control/vtol_type.cpp +++ b/src/modules/vtol_att_control/vtol_type.cpp @@ -231,14 +231,14 @@ float VtolType::update_and_get_backtransition_pitch_sp() float integrator_input = _params->dec_to_pitch_i * accel_error_forward; if ((pitch_sp_new >= pitch_lim && accel_error_forward > 0.0f) || - (pitch_sp_new <= -pitch_lim && accel_error_forward < 0.0f)) { + (pitch_sp_new <= 0.f && accel_error_forward < 0.0f)) { integrator_input = 0.0f; } _accel_to_pitch_integ += integrator_input * _transition_dt; - - return math::constrain(pitch_sp_new, -pitch_lim, pitch_lim); + // only allow positive (pitch up) pitch setpoint + return math::constrain(pitch_sp_new, 0.f, pitch_lim); } bool VtolType::can_transition_on_ground()