Change control allocation mixer during flight

Hello, I am trying to implement fault tolerant control by changing the control allocation matrix during flight.

I figured out that the mixers are generated at mixer_multirotor_normalized.generated.h.

However, I cannot figure out how to change the mixer in the cpp file.

If I can figure out how to change the mixer in the cpp file, I think I can change the mixer during flight (via parameter or after certain time period)

Any help is appreciated.

Thank you, Kangmin

Hi @kangmin7 ,

We’re in the process of moving away from fixed mixer to dynamic control allocation.
The control allocation module is there: PX4-Autopilot/src/modules/control_allocator at master · PX4/PX4-Autopilot · GitHub and can be activated using SYS_CTRL_ALLOC.

In multirotor mode (when CA_AIRFRAME is set to 0), the control allocator module takes the geometry from CA_MC_xxx parameters, builds the effectiveness matrix and invert it to produce the control allocation matrix (see PX4-Autopilot/ControlAllocationPseudoInverse.cpp at d0f89f7fff0328ff92cd62af0506b42b2d31106d · PX4/PX4-Autopilot · GitHub). Then, whenever the geometry is changed (e.g.: motor failure), the control allocation matrix can be recomputed using the same process (failure detection still needs to be implementer, but you can already try to change it via the CA_MC_xxx parameters).

Good luck!

@bresch

Thank you for your answer! I will try it out

Kangmin Lee

p.s. Loading new mixer in the SD card using

mixer load /dev/pwm_output0 /etc/mixers/<test_mixer>.mix

also works during the flight in HITL! This is the current method I’m using right now