From dfced1fe46d47fab2c369360920e459364233d73 Mon Sep 17 00:00:00 2001 From: GaspardBesacier <115625131+GaspardBesacier@users.noreply.github.com> Date: Mon, 14 Nov 2022 16:32:51 +0100 Subject: [PATCH] VTOL: Smarter pusher ramp up during front transtitions for standard VTOLs (#20394) New param VT_PSHER_SLEW for ramping up throttle of pusher during front/back transition, that replaces the old VT_PSHER_RMP_DT param. --- src/lib/parameters/param_translation.cpp | 11 +++++++++++ src/modules/vtol_att_control/standard.cpp | 10 +++++----- src/modules/vtol_att_control/standard.h | 2 +- src/modules/vtol_att_control/standard_params.c | 14 ++++++++------ 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/lib/parameters/param_translation.cpp b/src/lib/parameters/param_translation.cpp index e0c4b4d6ad..5ec98ef16d 100644 --- a/src/lib/parameters/param_translation.cpp +++ b/src/lib/parameters/param_translation.cpp @@ -259,5 +259,16 @@ bool param_modify_on_import(bson_node_t node) } } + // 2022-11-11: translate VT_F_TRANS_THR/VT_PSHER_RMP_DT -> VT_PSHER_SLEW + { + if (strcmp("VT_PSHER_RMP_DT", node->name) == 0) { + strcpy(node->name, "VT_PSHER_SLEW"); + double _param_vt_f_trans_thr = param_find("VT_F_TRANS_THR"); + node->d = _param_vt_f_trans_thr / node->d; + PX4_INFO("copying %s -> %s", "VT_PSHER_RMP_DT", "VT_PSHER_SLEW"); + return true; + } + } + return false; } diff --git a/src/modules/vtol_att_control/standard.cpp b/src/modules/vtol_att_control/standard.cpp index 96dbfb37d5..635376ddcf 100644 --- a/src/modules/vtol_att_control/standard.cpp +++ b/src/modules/vtol_att_control/standard.cpp @@ -231,13 +231,14 @@ void Standard::update_transition_state() } if (_vtol_schedule.flight_mode == vtol_mode::TRANSITION_TO_FW) { - if (_param_vt_psher_rmp_dt.get() <= 0.0f) { + if (_param_vt_psher_slew.get() <= FLT_EPSILON) { // just set the final target throttle value _pusher_throttle = _param_vt_f_trans_thr.get(); } else if (_pusher_throttle <= _param_vt_f_trans_thr.get()) { // ramp up throttle to the target throttle value - _pusher_throttle = _param_vt_f_trans_thr.get() * time_since_trans_start / _param_vt_psher_rmp_dt.get(); + _pusher_throttle = math::min(_pusher_throttle + + _param_vt_psher_slew.get() * _dt, _param_vt_f_trans_thr.get()); } _airspeed_trans_blend_margin = _param_vt_arsp_trans.get() - _param_vt_arsp_blend.get(); @@ -291,9 +292,8 @@ void Standard::update_transition_state() if (time_since_trans_start >= _param_vt_b_rev_del.get()) { // Handle throttle reversal for active breaking - float thrscale = (time_since_trans_start - _param_vt_b_rev_del.get()) / (_param_vt_psher_rmp_dt.get()); - thrscale = math::constrain(thrscale, 0.0f, 1.0f); - _pusher_throttle = thrscale * _param_vt_b_trans_thr.get(); + _pusher_throttle = math::constrain((time_since_trans_start - _param_vt_b_rev_del.get()) + * _param_vt_psher_slew.get(), 0.0f, _param_vt_b_trans_thr.get()); } // continually increase mc attitude control as we transition back to mc mode diff --git a/src/modules/vtol_att_control/standard.h b/src/modules/vtol_att_control/standard.h index 70963e008f..fd09f18ce2 100644 --- a/src/modules/vtol_att_control/standard.h +++ b/src/modules/vtol_att_control/standard.h @@ -84,7 +84,7 @@ private: void parameters_update() override; DEFINE_PARAMETERS_CUSTOM_PARENT(VtolType, - (ParamFloat) _param_vt_psher_rmp_dt, + (ParamFloat) _param_vt_psher_slew, (ParamFloat) _param_vt_b_trans_ramp, (ParamFloat) _param_fw_psp_off, (ParamFloat) _param_vt_b_rev_out, diff --git a/src/modules/vtol_att_control/standard_params.c b/src/modules/vtol_att_control/standard_params.c index 317e991e4e..26b74efc61 100644 --- a/src/modules/vtol_att_control/standard_params.c +++ b/src/modules/vtol_att_control/standard_params.c @@ -108,7 +108,7 @@ PARAM_DEFINE_FLOAT(VT_B_REV_OUT, 0.0f); * * Set this to a value greater than 0 to give the motor time to spin down. * - * unit s + * @unit s * @min 0 * @max 10 * @increment 1 @@ -118,14 +118,16 @@ PARAM_DEFINE_FLOAT(VT_B_REV_OUT, 0.0f); PARAM_DEFINE_FLOAT(VT_B_REV_DEL, 0.0f); /** - * Pusher throttle ramp up window + * Pusher throttle ramp up slew rate * - * Defines the time window during which the pusher throttle will be ramped up linearly to VT_F_TRANS_THR during a transition - * to fixed wing mode. Zero or negative values will produce an instant throttle rise to VT_F_TRANS_THR. + * Defines the slew rate of the puller/pusher throttle during transitions. + * Zero will deactivate the slew rate limiting and thus produce an instant throttle + * rise to the transition throttle VT_F_TRANS_THR. * - * @max 20 + * @unit 1/s + * @min 0 * @increment 0.01 * @decimal 2 * @group VTOL Attitude Control */ -PARAM_DEFINE_FLOAT(VT_PSHER_RMP_DT, 3.0f); +PARAM_DEFINE_FLOAT(VT_PSHER_SLEW, 0.33f);