From 3943025f32906713ade0fa59eb021dc13d939d47 Mon Sep 17 00:00:00 2001 From: somebody-once-told-me <155648712+somebody-once-told-me@users.noreply.github.com> Date: Wed, 20 Nov 2024 03:52:36 -0500 Subject: [PATCH] Centralize yaw margin (#23982) --- .../ControlAllocationSequentialDesaturation.cpp | 2 +- .../ControlAllocationSequentialDesaturation.hpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturation.cpp b/src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturation.cpp index 83be2a3b33..4b28f44dac 100644 --- a/src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturation.cpp +++ b/src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturation.cpp @@ -219,7 +219,7 @@ ControlAllocationSequentialDesaturation::mixYaw() // Change yaw acceleration to unsaturate the outputs if needed (do not change roll/pitch), // and allow some yaw response at maximum thrust ActuatorVector max_prev = _actuator_max; - _actuator_max += (_actuator_max - _actuator_min) * 0.15f; + _actuator_max += (_actuator_max - _actuator_min) * MINIMUM_YAW_MARGIN; desaturateActuators(_actuator_sp, yaw); _actuator_max = max_prev; diff --git a/src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturation.hpp b/src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturation.hpp index 53c422cd39..dfa69d9777 100644 --- a/src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturation.hpp +++ b/src/modules/control_allocator/ControlAllocation/ControlAllocationSequentialDesaturation.hpp @@ -57,6 +57,10 @@ public: void allocate() override; void updateParameters() override; + + // This is the minimum actuator yaw granted when the controller is saturated. + // In the yaw-only case where outputs are saturated, thrust is reduced by up to this amount. + static constexpr float MINIMUM_YAW_MARGIN{0.15f}; private: /**