vtol_type: transition altitude loss quad-chute: handle z resets

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
Silvan Fuhrer 2023-11-20 16:30:22 +01:00
parent 8a899170bf
commit eae939d86c
2 changed files with 8 additions and 0 deletions

View File

@ -302,6 +302,12 @@ bool VtolType::isFrontTransitionAltitudeLoss()
{
bool result = false;
// check if there is a reset in the z-direction, and if so, shift the transition start z as well
if (_local_pos->z_reset_counter != _altitude_reset_counter) {
_local_position_z_start_of_transition += _local_pos->delta_z;
_altitude_reset_counter = _local_pos->z_reset_counter;
}
// only run if param set, altitude valid and controlled, and in transition to FW or within 5s of finishing it.
if (_param_vt_qc_t_alt_loss.get() > FLT_EPSILON && _local_pos->z_valid && _v_control_mode->flag_control_altitude_enabled
&& (_common_vtol_mode == mode::TRANSITION_TO_FW || hrt_elapsed_time(&_trans_finished_ts) < 5_s)) {

View File

@ -330,6 +330,8 @@ protected:
float _local_position_z_start_of_transition{0.f}; // altitude at start of transition
int _altitude_reset_counter{0};
DEFINE_PARAMETERS_CUSTOM_PARENT(ModuleParams,
(ParamBool<px4::params::VT_ELEV_MC_LOCK>) _param_vt_elev_mc_lock,
(ParamFloat<px4::params::VT_FW_MIN_ALT>) _param_vt_fw_min_alt,