fix(control_allocation): drop control axes that are not independently achievable (#28589)

* fix(control_allocation): drop control axes that are not independently achievable

Stopping a hexarotor motor and its geometric opposite (CA_FAILURE_MODE=1)
leaves four rotors whose roll and yaw effectiveness rows are collinear -
exactly so on ideal geometry, 1.3 deg apart on a surveyed airframe. Yaw is
no longer independently controllable, but nothing in control allocation
checked for that, so geninv inverted a near-singular matrix and returned a
mix with roll gains ~50x and thrust gains ~2000x with random signs
(Moore-Penrose residual 1e4). Sequential desaturation cannot recover from
gains that large and left ~0.85 on two rotors at zero thrust demand: a
vehicle armed on the ground at idle lifted off by itself.

dropDependentAxes() walks the effectiveness rows in priority order
(thrust z, roll, pitch, thrust x, thrust y, yaw) and zeroes any row whose
component orthogonal to the higher-priority rows falls below
kMinAxisIndependence = 1e-2, i.e. within ~5.7 deg of their span. The axis
becomes explicitly unachievable and is reported through the dropped-axis
mask instead of being inverted into garbage.

The metric is unit-free, so it does not depend on CA_ROTORn_KM or arm
length: verified identical decisions for KM from 0.003 to 0.5 and arms from
0.05 m to 5 m. Across in-tree geometries healthy multirotors score 1.00,
hexa/octo with one motor out 0.75/0.89 and tailsitter 0.70, none affected;
only quad-with-one-motor-out and hexarotor failed+opposite drop yaw.

The orthogonalization runs through the Cholesky factor of the Gram matrix
of the accepted unit rows rather than on the rows themselves, so no
NUM_ACTUATORS-long vectors land on the stack: 288 B of frame instead of
632 B, which matters because this runs on wq:rate_ctrl with 3150 B.

Co-Authored-By: Matthias Grob <maetugr@gmail.com>

* feat(matrix): add dot product for matrix::Slice

* fix(control_allocation): replace custom rowDot() with new matrix::Slice::dot()

---------

Co-authored-by: Matthias Grob <maetugr@gmail.com>
This commit is contained in:
Claudio ChiesandMatthias Grob authored and GitHub committed 2026-09-11 08:21:34 +02:00
1 parent 4565d0db06
commit 9a0e5ab7f0
9 files changed
+356 -2

No files matched your search

@@ -447,6 +447,8 @@ ControlAllocator::Run()
}
_control_allocation[i]->clipActuatorSetpoint();
check_allocation_health(i);
}
}
@@ -634,6 +636,23 @@ ControlAllocator::handle_stopped_motors(const hrt_abstime now)
}
}
void
ControlAllocator::check_allocation_health(int matrix_index)
{
const uint8_t dropped_axes = _control_allocation[matrix_index]->getDroppedAxes();
if (dropped_axes != _dropped_axes_reported[matrix_index]) {
_dropped_axes_reported[matrix_index] = dropped_axes;
if (dropped_axes != 0) {
PX4_WARN("Control allocation %i: dropped dependent control axes 0x%x", matrix_index, dropped_axes);
} else {
PX4_INFO("Control allocation %i: all control axes restored", matrix_index);
}
}
}
void
ControlAllocator::publish_control_allocator_status(int matrix_index)
{
@@ -1031,6 +1050,10 @@ int ControlAllocator::print_status()
printf("\n");
PX4_INFO(" Configured actuators: %i", num_configured);
if (_control_allocation[i]->getDroppedAxes() != 0) {
PX4_INFO(" Dropped control axes: 0x%x", _control_allocation[i]->getDroppedAxes());
}
}
if (_handled_motor_failure_bitmask) {
@@ -148,6 +148,8 @@ private:
void publish_control_allocator_status(int matrix_index);
void check_allocation_health(int matrix_index);
void publish_actuator_controls();
void handle_stopped_motors(const hrt_abstime now);
@@ -159,6 +161,8 @@ private:
int _num_control_allocation{0};
hrt_abstime _last_effectiveness_update{0};
uint8_t _dropped_axes_reported[ActuatorEffectiveness::MAX_NUM_MATRICES] {};
enum class EffectivenessSource {
NONE = -1,
MULTIROTOR = 0,