From 41dee3875eb492e8ff006b9615c3c05d90152d5b Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Tue, 20 Aug 2019 13:50:34 -0400 Subject: [PATCH] VTOL: only run on actuator publications corresponding to VTOL mode --- .../vtol_att_control_main.cpp | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/modules/vtol_att_control/vtol_att_control_main.cpp b/src/modules/vtol_att_control/vtol_att_control_main.cpp index 97b604d963..ad6890ca7d 100644 --- a/src/modules/vtol_att_control/vtol_att_control_main.cpp +++ b/src/modules/vtol_att_control/vtol_att_control_main.cpp @@ -311,10 +311,28 @@ VtolAttitudeControl::Run() perf_begin(_loop_perf); perf_count(_loop_interval_perf); - bool updated_fw_in = _actuator_inputs_fw.update(&_actuators_fw_in); - bool updated_mc_in = _actuator_inputs_mc.update(&_actuators_mc_in); + const bool updated_fw_in = _actuator_inputs_fw.update(&_actuators_fw_in); + const bool updated_mc_in = _actuator_inputs_mc.update(&_actuators_mc_in); - if (updated_fw_in || updated_mc_in) { + // run on actuator publications corresponding to VTOL mode + bool should_run = false; + + switch (_vtol_type->get_mode()) { + case mode::TRANSITION_TO_FW: + case mode::TRANSITION_TO_MC: + should_run = updated_fw_in || updated_mc_in; + break; + + case mode::ROTARY_WING: + should_run = updated_mc_in; + break; + + case mode::FIXED_WING: + should_run = updated_fw_in; + break; + } + + if (should_run) { /* only update parameters if they changed */ if (_params_sub.updated()) { /* read from param to clear updated flag */