Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiltrotor: VTOL back-transition: expose tilting time as parameter and reduce overall duration #21760

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 1.0f
#define BACKTRANS_THROTTLE_UPRAMP_DUR_S 1.0f;
#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);
Loading