VTOL: make const and return when either of mc or fw att sp isn't updated

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
Silvan Fuhrer 2022-09-29 13:44:21 +02:00
parent fdcbabeb9e
commit f89df9d986
2 changed files with 4 additions and 4 deletions

View File

@ -205,7 +205,7 @@ void Standard::update_transition_state()
{
const hrt_abstime now = hrt_absolute_time();
float mc_weight = 1.0f;
float time_since_trans_start = (float)(now - _vtol_schedule.transition_start) * 1e-6f;
const float time_since_trans_start = (float)(now - _vtol_schedule.transition_start) * 1e-6f;
VtolType::update_transition_state();
@ -213,7 +213,7 @@ void Standard::update_transition_state()
// in any other case the fixed wing attitude controller publishes attitude setpoint from manual stick input.
if (_v_control_mode->flag_control_climb_rate_enabled) {
// we need the incoming (virtual) attitude setpoints (both mc and fw) to be recent, otherwise return (means the previous setpoint stays active)
if (_mc_virtual_att_sp->timestamp < (now - 1_s) && _fw_virtual_att_sp->timestamp < (now - 1_s)) {
if (_mc_virtual_att_sp->timestamp < (now - 1_s) || _fw_virtual_att_sp->timestamp < (now - 1_s)) {
return;
}

View File

@ -286,7 +286,7 @@ void Tiltrotor::update_transition_state()
// in any other case the fixed wing attitude controller publishes attitude setpoint from manual stick input.
if (_v_control_mode->flag_control_climb_rate_enabled) {
// we need the incoming (virtual) attitude setpoints (both mc and fw) to be recent, otherwise return (means the previous setpoint stays active)
if (_mc_virtual_att_sp->timestamp < (now - 1_s) && _fw_virtual_att_sp->timestamp < (now - 1_s)) {
if (_mc_virtual_att_sp->timestamp < (now - 1_s) || _fw_virtual_att_sp->timestamp < (now - 1_s)) {
return;
}
@ -304,7 +304,7 @@ void Tiltrotor::update_transition_state()
_thrust_transition = _fw_virtual_att_sp->thrust_body[0];
}
float time_since_trans_start = (float)(now - _vtol_schedule.transition_start) * 1e-6f;
const float time_since_trans_start = (float)(now - _vtol_schedule.transition_start) * 1e-6f;
if (_vtol_schedule.flight_mode == vtol_mode::TRANSITION_FRONT_P1) {
// for the first part of the transition all rotors are enabled