From b1da6f760afe34d16d825669e361a8e592392f73 Mon Sep 17 00:00:00 2001 From: Balduin Date: Thu, 8 Jan 2026 11:21:23 +0100 Subject: [PATCH] ControlAllocator: unnamed scope for clarity --- .../control_allocator/ControlAllocator.cpp | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/modules/control_allocator/ControlAllocator.cpp b/src/modules/control_allocator/ControlAllocator.cpp index 6261327165..edf18da4e9 100644 --- a/src/modules/control_allocator/ControlAllocator.cpp +++ b/src/modules/control_allocator/ControlAllocator.cpp @@ -397,24 +397,27 @@ ControlAllocator::Run() if (do_update) { _last_run = now; - check_for_motor_failures(); + // Decide if and for what reasons the effectiveness matrix needs updating + { + check_for_motor_failures(); - const hrt_abstime time_since_last_effectiveness_udpate = now - _last_effectiveness_update; + const hrt_abstime time_since_last_effectiveness_udpate = now - _last_effectiveness_update; - // If the above check_for_motor_failures has already triggered - // an effectiveness update, these timing checks all return false - // and no additional update is done. This is by design, because - // an effectiveness update due to MOTOR_ACTIVATION_UPDATE also - // updates the battery scale and directions of tiltable rotors. + // If the above check_for_motor_failures has already triggered + // an effectiveness update, these timing checks all return false + // and no additional update is done. This is by design, because + // an effectiveness update due to MOTOR_ACTIVATION_UPDATE also + // updates the battery scale and directions of tiltable rotors. - if (time_since_last_effectiveness_udpate > 1_s) { - // Update battery scaling at relatively low rate - update_effectiveness_matrix_if_needed(EffectivenessUpdateReason::BATTERY_SCALE_UPDATE); + if (time_since_last_effectiveness_udpate > 1_s) { + // Update battery scaling at relatively low rate + update_effectiveness_matrix_if_needed(EffectivenessUpdateReason::BATTERY_SCALE_UPDATE); - } else if (time_since_last_effectiveness_udpate > 100_ms) { - // Update periodically for "no external" reason, - // allowing tiltrotor directions to update. - update_effectiveness_matrix_if_needed(EffectivenessUpdateReason::NO_EXTERNAL_UPDATE); + } else if (time_since_last_effectiveness_udpate > 100_ms) { + // Update periodically for "no external" reason, + // allowing tiltrotor directions to update. + update_effectiveness_matrix_if_needed(EffectivenessUpdateReason::NO_EXTERNAL_UPDATE); + } } // Set control setpoint vector(s)