mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-26 01:00:36 +08:00
fix(vtol_att_control): share the front transition blend between standard VTOL and tiltrotor
Tiltrotors ramped the multicopter weight from VT_TRANS_MIN_TM to VT_F_TR_OL_TM, which becomes a step when both are equal. Move the standard VTOL blend into VtolType and use it for both: linear from VT_ARSP_BLEND to VT_ARSP_TRANS, with the constant-acceleration airspeed estimate when there is no airspeed feedback. VT_TRANS_MIN_TM keeps its single meaning as a minimum time, so blending is no longer delayed until it: a vehicle already above VT_ARSP_BLEND then stepped from full multicopter weight to the airspeed-based weight. Assisted-by: Claude:claude-opus-5-5
This commit is contained in:
1 parent
c4e7635653
commit
3d811f9ff8
5 files changed
+22
-41
No files matched your search
@@ -155,30 +155,13 @@ void Standard::update_transition_state()
|
||||
_last_time_pusher_transition_update = now;
|
||||
}
|
||||
|
||||
_airspeed_trans_blend_margin = getTransitionAirspeed() - getBlendAirspeed();
|
||||
|
||||
float airspeed = _attc->get_calibrated_airspeed();
|
||||
|
||||
if (!PX4_ISFINITE(airspeed)) {
|
||||
// without airspeed feedback assume constant acceleration, reaching the transition airspeed at the open-loop time
|
||||
airspeed = getTransitionAirspeed() * _time_since_trans_start / getOpenLoopFrontTransitionTime();
|
||||
}
|
||||
|
||||
// do blending of mc and fw controls if a blending airspeed has been provided and the minimum transition time has passed
|
||||
if (_airspeed_trans_blend_margin > 0.0f &&
|
||||
airspeed > 0.0f &&
|
||||
airspeed >= getBlendAirspeed() &&
|
||||
_time_since_trans_start > getMinimumFrontTransitionTime()) {
|
||||
|
||||
mc_weight = 1.0f - fabsf(airspeed - getBlendAirspeed()) / _airspeed_trans_blend_margin;
|
||||
}
|
||||
mc_weight = getFrontTransitionMcWeight();
|
||||
|
||||
// ramp up FW_PSP_OFF
|
||||
pitch_body = math::radians(_param_fw_psp_off.get()) * (1.0f - mc_weight);
|
||||
_v_att_sp->thrust_body[0] = _pusher_throttle;
|
||||
const Quatf q_sp(Eulerf(roll_body, pitch_body, yaw_body));
|
||||
q_sp.copyTo(_v_att_sp->q_d);
|
||||
mc_weight = math::constrain(mc_weight, 0.0f, 1.0f);
|
||||
|
||||
} else if (_common_vtol_mode == mode::TRANSITION_TO_MC) {
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ public:
|
||||
|
||||
private:
|
||||
float _pusher_throttle{0.0f};
|
||||
float _airspeed_trans_blend_margin{0.0f};
|
||||
hrt_abstime _last_time_pusher_transition_update{0};
|
||||
float _front_transition_pitch{NAN};
|
||||
|
||||
|
||||
@@ -151,32 +151,13 @@ void Tiltrotor::update_transition_state()
|
||||
_tilt_control = math::max(_tilt_control, ramped_up_tilt);
|
||||
}
|
||||
|
||||
// at low speeds give full weight to MC. A back transition zeroes the pitch and throttle weights
|
||||
// while the rotors rotate, so a restarted front transition sets pitch and ramps the throttle back
|
||||
_mc_roll_weight = 1.0f;
|
||||
// A back transition zeroes the pitch and throttle weights while the rotors rotate,
|
||||
// so a restarted front transition sets pitch and ramps the throttle back
|
||||
_mc_roll_weight = getFrontTransitionMcWeight();
|
||||
_mc_pitch_weight = 1.0f;
|
||||
_mc_yaw_weight = 1.0f;
|
||||
_mc_throttle_weight = math::min(_mc_throttle_weight + _transition_dt / BACKTRANS_THROTTLE_UPRAMP_DUR_S, 1.0f);
|
||||
|
||||
const float airspeed_trans_blend_margin = getTransitionAirspeed() - getBlendAirspeed();
|
||||
|
||||
if (airspeed_trans_blend_margin > FLT_EPSILON &&
|
||||
PX4_ISFINITE(_attc->get_calibrated_airspeed()) &&
|
||||
_attc->get_calibrated_airspeed() >= getBlendAirspeed()) {
|
||||
_mc_roll_weight = 1.0f - (_attc->get_calibrated_airspeed() - getBlendAirspeed()) /
|
||||
airspeed_trans_blend_margin;
|
||||
}
|
||||
|
||||
// without airspeed do timed weight changes
|
||||
const float time_trans_open_loop_margin = getOpenLoopFrontTransitionTime() - getMinimumFrontTransitionTime();
|
||||
|
||||
if ((!PX4_ISFINITE(_attc->get_calibrated_airspeed())) &&
|
||||
time_trans_open_loop_margin > FLT_EPSILON &&
|
||||
_time_since_trans_start > getMinimumFrontTransitionTime()) {
|
||||
_mc_roll_weight = 1.0f - (_time_since_trans_start - getMinimumFrontTransitionTime()) /
|
||||
time_trans_open_loop_margin;
|
||||
}
|
||||
|
||||
// add minimum throttle for front transition
|
||||
_thrust_transition = math::max(_thrust_transition, FRONTTRANS_THR_MIN);
|
||||
|
||||
|
||||
@@ -668,6 +668,19 @@ float VtolType::getOpenLoopFrontTransitionTime() const
|
||||
{
|
||||
return getFrontTransitionTimeFactor() * _param_vt_f_tr_ol_tm.get();
|
||||
}
|
||||
|
||||
float VtolType::getFrontTransitionMcWeight() const
|
||||
{
|
||||
float airspeed = _attc->get_calibrated_airspeed();
|
||||
|
||||
if (!PX4_ISFINITE(airspeed)) {
|
||||
// without airspeed feedback assume constant acceleration, reaching the transition airspeed at the open-loop time
|
||||
airspeed = getTransitionAirspeed() * _time_since_trans_start / getOpenLoopFrontTransitionTime();
|
||||
}
|
||||
|
||||
return math::interpolate(airspeed, getBlendAirspeed(), getTransitionAirspeed(), 1.f, 0.f);
|
||||
}
|
||||
|
||||
float VtolType::getTransitionAirspeed() const
|
||||
{
|
||||
// Since the stall airspeed increases with vehicle weight, we increase the transition airspeed
|
||||
|
||||
@@ -240,6 +240,11 @@ public:
|
||||
*/
|
||||
float getOpenLoopFrontTransitionTime() const;
|
||||
|
||||
/**
|
||||
* @return Multicopter weight during a front transition, blended out from the blend to the transition airspeed [0, 1]
|
||||
*/
|
||||
float getFrontTransitionMcWeight() const;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The calibrated blending airspeed [m/s]
|
||||
|
||||
Reference in new issue
Block a user