VTOL: use the same logic for front transition complete in all vtol types

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
Silvan Fuhrer 2024-05-29 15:57:25 +02:00
parent a4650fd70d
commit 6552468df1
8 changed files with 18 additions and 32 deletions

View File

@ -361,3 +361,9 @@ void Standard::blendThrottleAfterFrontTransition(float scale)
const float tecs_throttle = _v_att_sp->thrust_body[0];
_v_att_sp->thrust_body[0] = scale * tecs_throttle + (1.0f - scale) * _pusher_throttle;
}
bool Standard::isFrontTransitionCompleted()
{
// no customization required, just use base from vtol_type
return VtolType::isFrontTransitionCompletedBase();
}

View File

@ -79,6 +79,7 @@ private:
hrt_abstime _last_time_pusher_transition_update{0};
void parameters_update() override;
bool isFrontTransitionCompleted();
DEFINE_PARAMETERS_CUSTOM_PARENT(VtolType,
(ParamFloat<px4::params::VT_PSHER_SLEW>) _param_vt_psher_slew,

View File

@ -310,23 +310,10 @@ void Tailsitter::fill_actuator_outputs()
}
}
bool Tailsitter::isFrontTransitionCompletedBase()
bool Tailsitter::isFrontTransitionCompleted()
{
const bool airspeed_triggers_transition = PX4_ISFINITE(_airspeed_validated->calibrated_airspeed_m_s)
&& _param_fw_use_airspd.get();
bool transition_to_fw = false;
// tailsitter only: add check pitch angle
const float pitch = Eulerf(Quatf(_v_att->q)).theta();
if (pitch <= PITCH_THRESHOLD_AUTO_TRANSITION_TO_FW) {
if (airspeed_triggers_transition) {
transition_to_fw = _airspeed_validated->calibrated_airspeed_m_s >= _param_vt_arsp_trans.get() ;
} else {
transition_to_fw = true;
}
}
return transition_to_fw;
return VtolType::isFrontTransitionCompletedBase() && pitch <= PITCH_THRESHOLD_AUTO_TRANSITION_TO_FW;
}

View File

@ -85,7 +85,7 @@ private:
void parameters_update() override;
bool isFrontTransitionCompletedBase() override;
bool isFrontTransitionCompleted();
DEFINE_PARAMETERS_CUSTOM_PARENT(VtolType,
(ParamFloat<px4::params::FW_PSP_OFF>) _param_fw_psp_off

View File

@ -426,7 +426,8 @@ float Tiltrotor::moveLinear(float start, float stop, float progress)
return start + progress * (stop - start);
}
bool Tiltrotor::isFrontTransitionCompletedBase()
bool Tiltrotor::isFrontTransitionCompleted()
{
return VtolType::isFrontTransitionCompletedBase() && _tilt_control >= _param_vt_tilt_trans.get();
// tiltrotor only: add check on tilt control
return (VtolType::isFrontTransitionCompletedBase() && _tilt_control >= _param_vt_tilt_trans.get());
}

View File

@ -89,8 +89,7 @@ private:
float moveLinear(float start, float stop, float progress);
void blendThrottleDuringBacktransition(const float scale, const float target_throttle);
bool isFrontTransitionCompletedBase() override;
bool isFrontTransitionCompleted();
DEFINE_PARAMETERS_CUSTOM_PARENT(VtolType,
(ParamFloat<px4::params::VT_TILT_MC>) _param_vt_tilt_mc,

View File

@ -197,13 +197,6 @@ float VtolType::update_and_get_backtransition_pitch_sp()
return math::constrain(pitch_sp_new, 0.f, pitch_lim);
}
bool VtolType::isFrontTransitionCompleted()
{
bool ret = isFrontTransitionCompletedBase();
return ret || can_transition_on_ground();
}
bool VtolType::isFrontTransitionCompletedBase()
{
// continue the transition to fw mode while monitoring airspeed for a final switch to fw mode
@ -222,8 +215,7 @@ bool VtolType::isFrontTransitionCompletedBase()
transition_to_fw = openloop_trans_time_elapsed;
}
return transition_to_fw;
return (transition_to_fw || can_transition_on_ground());
}
bool VtolType::can_transition_on_ground()

View File

@ -317,8 +317,8 @@ protected:
bool _quadchute_command_treated{false};
float update_and_get_backtransition_pitch_sp();
bool isFrontTransitionCompleted();
virtual bool isFrontTransitionCompletedBase();
bool isFrontTransitionCompletedBase();
virtual bool isFrontTransitionCompleted() = 0;
float _local_position_z_start_of_transition{0.f}; // altitude at start of transition