From db2a53d95df220b1e7df1ab99655b59d254575f8 Mon Sep 17 00:00:00 2001 From: tumbili Date: Tue, 29 Mar 2016 10:38:02 +0200 Subject: [PATCH] added parameter to allow scaling the forward thrust used to acclerate forward in multirotor mode --- src/modules/vtol_att_control/standard.cpp | 8 +++++++- src/modules/vtol_att_control/standard.h | 2 ++ src/modules/vtol_att_control/standard_params.c | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/modules/vtol_att_control/standard.cpp b/src/modules/vtol_att_control/standard.cpp index 6f79a7da2e..3b5e627679 100644 --- a/src/modules/vtol_att_control/standard.cpp +++ b/src/modules/vtol_att_control/standard.cpp @@ -67,6 +67,7 @@ Standard::Standard(VtolAttitudeControl *attc) : _params_handles_standard.front_trans_timeout = param_find("VT_TRANS_TIMEOUT"); _params_handles_standard.front_trans_time_min = param_find("VT_TRANS_MIN_TM"); _params_handles_standard.down_pitch_max = param_find("VT_DWN_PITCH_MAX"); + _params_handles_standard.forward_thurst_scale = param_find("VT_FWD_THRUST_SC"); } Standard::~Standard() @@ -110,6 +111,10 @@ Standard::parameters_update() param_get(_params_handles_standard.down_pitch_max, &v); _params_standard.down_pitch_max = math::radians(v); + /* scale for fixed wing thrust used for forward acceleration in multirotor mode */ + param_get(_params_handles_standard.forward_thurst_scale, &_params_standard.forward_thurst_scale); + + return OK; } @@ -297,7 +302,8 @@ void Standard::update_mc_state() R.from_euler(0, 0, euler(2)); math::Vector<3> body_x_zero_tilt(R(0,0), R(1,0), R(2,0)); - _pusher_throttle = body_x_zero_tilt * thrust_sp_axis * _v_att_sp->thrust; + // we are using a parameter to scale the thrust value in order to compensate for highly over/under-powered motors + _pusher_throttle = body_x_zero_tilt * thrust_sp_axis * _v_att_sp->thrust * _params_standard.forward_thurst_scale; _pusher_throttle = _pusher_throttle < 0.0f ? 0.0f : _pusher_throttle; float pitch_sp_corrected = _v_att_sp->pitch_body < -_params_standard.down_pitch_max ? -_params_standard.down_pitch_max : _v_att_sp->pitch_body; diff --git a/src/modules/vtol_att_control/standard.h b/src/modules/vtol_att_control/standard.h index 4b4f9ecc42..ea578bf2bf 100644 --- a/src/modules/vtol_att_control/standard.h +++ b/src/modules/vtol_att_control/standard.h @@ -75,6 +75,7 @@ private: float front_trans_timeout; float front_trans_time_min; float down_pitch_max; + float forward_thurst_scale; } _params_standard; struct { @@ -86,6 +87,7 @@ private: param_t front_trans_timeout; param_t front_trans_time_min; param_t down_pitch_max; + param_t forward_thurst_scale; } _params_handles_standard; enum vtol_mode { diff --git a/src/modules/vtol_att_control/standard_params.c b/src/modules/vtol_att_control/standard_params.c index 6d783a23f1..ab57e628e1 100644 --- a/src/modules/vtol_att_control/standard_params.c +++ b/src/modules/vtol_att_control/standard_params.c @@ -60,3 +60,14 @@ PARAM_DEFINE_FLOAT(VT_TRANS_THR, 0.6f); * @group VTOL Attitude Control */ PARAM_DEFINE_FLOAT(VT_DWN_PITCH_MAX, 5.0f); + +/** + * Fixed wing thrust scale for hover forward flight. + * + * Scale applied to fixed wing thrust being used as source for forward acceleration in multirotor mode. + * This technique can be used to avoid the plane having to pitch down a lot in order to move forward. + * @min 0.0 + * @max 2.0 + * @group VTOL Attitude Control + */ +PARAM_DEFINE_FLOAT(VT_FWD_THRUST_SC, 1.0f);