mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-15 23:33:34 +08:00
ControlAllocator: unnamed scope for clarity
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user