VTOL: only run on actuator publications corresponding to VTOL mode

This commit is contained in:
Daniel Agar 2019-08-20 13:50:34 -04:00 committed by GitHub
parent be233f6bc7
commit 41dee3875e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 3 deletions

View File

@ -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 */