diff --git a/src/modules/vtol_att_control/standard.cpp b/src/modules/vtol_att_control/standard.cpp index 4e56865b216..9d29c18aee6 100644 --- a/src/modules/vtol_att_control/standard.cpp +++ b/src/modules/vtol_att_control/standard.cpp @@ -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) { diff --git a/src/modules/vtol_att_control/standard.h b/src/modules/vtol_att_control/standard.h index 3da989752ff..3354e84d4a7 100644 --- a/src/modules/vtol_att_control/standard.h +++ b/src/modules/vtol_att_control/standard.h @@ -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}; diff --git a/src/modules/vtol_att_control/tiltrotor.cpp b/src/modules/vtol_att_control/tiltrotor.cpp index f33b4668e52..bac312f0a69 100644 --- a/src/modules/vtol_att_control/tiltrotor.cpp +++ b/src/modules/vtol_att_control/tiltrotor.cpp @@ -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); diff --git a/src/modules/vtol_att_control/vtol_type.cpp b/src/modules/vtol_att_control/vtol_type.cpp index a9d05ded977..b8e48a7ba43 100644 --- a/src/modules/vtol_att_control/vtol_type.cpp +++ b/src/modules/vtol_att_control/vtol_type.cpp @@ -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 diff --git a/src/modules/vtol_att_control/vtol_type.h b/src/modules/vtol_att_control/vtol_type.h index 42975dac060..a0ded5bcdcf 100644 --- a/src/modules/vtol_att_control/vtol_type.h +++ b/src/modules/vtol_att_control/vtol_type.h @@ -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]