Custom ControlAllocation logic in case of Rotor failure

I am an enthusiastic engineering student currently working on an exciting project involving UAV development. My focus is on implementing a safe mechanism for a quadcopter in case of rotor failure.

So far, I have successfully developed an ML-based model that detects rotor failure using real-time onboard sensor data. My next step involves mapping control commands to the remaining three motors when a rotor fails.

After some research, I discovered that the latest PX4 versions use the Control Allocator module instead of mixer files. To proceed, I started working on a custom ControlAllocator.cpp and ActuatorEffectivenessCustom.cpp, but I am currently facing some challenges.

Here’s a brief summary of my approach:

I plan to use custom logic to adjust the control allocation matrix dynamically based on rotor failure conditions.

The goal is to redistribute roll, pitch, and thrust commands across the remaining motors efficiently.

I would greatly appreciate your advice on the following:

  1. Best practices for modifying ControlAllocator.cpp and ActuatorEffectivenessCustom.cpp to handle rotor failure.

  2. How to integrate my custom files properly within the PX4 build system to avoid compilation errors.

  3. Any suggestions for testing and debugging the new control logic using PX4 SITL.

Not sure what you mean with best practices. As a first step you have to make the required changes and get it working in simulation. Once you have that, you can think about how you can extract it, so it’s not conflicting with upstream. That’s only really required if you’re planning to maintain the fork or if you plan on contributing it back upstream.

Not sure. What are the errors? This seems more like a C++ question.

Try in SITL first.