Skip to content

Commit

Permalink
tiltrotor: expose tilting duration of backtransition in param
Browse files Browse the repository at this point in the history
Instead of hard-coding the tilting duration (from FW to MC tilt),
expose it as a parameter (VT_BT_TILT_DUR). The default is the same
as the hard-coded value previously (1s).
Slower tilting mechanisms need a higher value here, while for smaller
ones a too high value results in unnecessary delays till the motors
are in hover configuration.

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
  • Loading branch information
sfuhrer committed Jun 26, 2023
1 parent 92c22cf commit 4113597
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/modules/vtol_att_control/tiltrotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@
using namespace matrix;
using namespace time_literals;

#define FRONTTRANS_THR_MIN 0.25f
#define BACKTRANS_THROTTLE_DOWNRAMP_DUR_S 0.5f;
#define BACKTRANS_THROTTLE_UPRAMP_DUR_S 0.5f;
#define BACKTRANS_MOTORS_UPTILT_DUR_S 1.0f;
#define FRONTTRANS_THR_MIN 0.25f
#define BACKTRANS_THROTTLE_DOWNRAMP_DUR_S 0.5f
#define BACKTRANS_THROTTLE_UPRAMP_DUR_S 0.5f

Tiltrotor::Tiltrotor(VtolAttitudeControl *attc) :
VtolType(attc)
Expand Down Expand Up @@ -321,7 +320,8 @@ void Tiltrotor::update_transition_state()
// tilt rotors back once motors are idle
if (_time_since_trans_start > BACKTRANS_THROTTLE_DOWNRAMP_DUR_S) {

float progress = (_time_since_trans_start - BACKTRANS_THROTTLE_DOWNRAMP_DUR_S) / BACKTRANS_MOTORS_UPTILT_DUR_S;
float progress = (_time_since_trans_start - BACKTRANS_THROTTLE_DOWNRAMP_DUR_S) / math::max(_param_vt_bt_tilt_dur.get(),
0.1f);
progress = math::constrain(progress, 0.0f, 1.0f);
_tilt_control = moveLinear(_param_vt_tilt_fw.get(), _param_vt_tilt_mc.get(), progress);
}
Expand Down Expand Up @@ -458,7 +458,7 @@ void Tiltrotor::blendThrottleDuringBacktransition(float scale, float target_thro

float Tiltrotor::timeUntilMotorsAreUp()
{
return BACKTRANS_THROTTLE_DOWNRAMP_DUR_S + BACKTRANS_MOTORS_UPTILT_DUR_S;
return BACKTRANS_THROTTLE_DOWNRAMP_DUR_S + _param_vt_bt_tilt_dur.get();
}

float Tiltrotor::moveLinear(float start, float stop, float progress)
Expand Down
3 changes: 2 additions & 1 deletion src/modules/vtol_att_control/tiltrotor.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class Tiltrotor : public VtolType
(ParamFloat<px4::params::VT_TILT_TRANS>) _param_vt_tilt_trans,
(ParamFloat<px4::params::VT_TILT_FW>) _param_vt_tilt_fw,
(ParamFloat<px4::params::VT_TILT_SPINUP>) _param_vt_tilt_spinup,
(ParamFloat<px4::params::VT_TRANS_P2_DUR>) _param_vt_trans_p2_dur
(ParamFloat<px4::params::VT_TRANS_P2_DUR>) _param_vt_trans_p2_dur,
(ParamFloat<px4::params::VT_BT_TILT_DUR>) _param_vt_bt_tilt_dur
)

};
Expand Down
14 changes: 14 additions & 0 deletions src/modules/vtol_att_control/tiltrotor_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,17 @@ PARAM_DEFINE_FLOAT(VT_TILT_SPINUP, 0.0f);
* @group VTOL Attitude Control
*/
PARAM_DEFINE_FLOAT(VT_TRANS_P2_DUR, 0.5f);

/**
* Duration motor tilt up in backtransition
*
* Time in seconds it takes to tilt form VT_TILT_FW to VT_TILT_MC.
*
* @unit s
* @min 0.1
* @max 10
* @increment 0.1
* @decimal 1
* @group VTOL Attitude Control
*/
PARAM_DEFINE_FLOAT(VT_BT_TILT_DUR, 1.f);

0 comments on commit 4113597

Please sign in to comment.