From 61e3ec53b077f5dbb96bbbbab3ad64949849804b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 10 Aug 2021 17:06:39 +0200 Subject: [PATCH] mixer_module: check for motor test after topic update Otherwise if a module restricts the update rate via setMaxTopicUpdateRate() and then motor_test is used, the module might run faster than expected. --- src/lib/mixer_module/mixer_module.cpp | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lib/mixer_module/mixer_module.cpp b/src/lib/mixer_module/mixer_module.cpp index e1eff51dc3..9d654785e5 100644 --- a/src/lib/mixer_module/mixer_module.cpp +++ b/src/lib/mixer_module/mixer_module.cpp @@ -351,21 +351,6 @@ bool MixingOutput::update() } } - // check for motor test - if (!_armed.armed && !_armed.manual_lockdown) { - unsigned num_motor_test = motorTest(); - - if (num_motor_test > 0) { - if (_interface.updateOutputs(false, _current_output_value, num_motor_test, 1)) { - actuator_outputs_s actuator_outputs{}; - setAndPublishActuatorOutputs(num_motor_test, actuator_outputs); - } - - handleCommands(); - return true; - } - } - if (_param_mot_slew_max.get() > FLT_EPSILON) { updateOutputSlewrateMultirotorMixer(); } @@ -396,6 +381,21 @@ bool MixingOutput::update() } } + // check for motor test (after topic updates) + if (!_armed.armed && !_armed.manual_lockdown) { + unsigned num_motor_test = motorTest(); + + if (num_motor_test > 0) { + if (_interface.updateOutputs(false, _current_output_value, num_motor_test, 1)) { + actuator_outputs_s actuator_outputs{}; + setAndPublishActuatorOutputs(num_motor_test, actuator_outputs); + } + + handleCommands(); + return true; + } + } + /* do mixing */ float outputs[MAX_ACTUATORS] {}; const unsigned mixed_num_outputs = _mixers->mix(outputs, _max_num_outputs);