mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-13 17:30:36 +08:00
tiltrotor: expose tilting duration of backtransition in param
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>
This commit is contained in:
@@ -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)
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -99,7 +99,8 @@ private:
|
||||
(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
|
||||
)
|
||||
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user