Best way to test a new control law

Sorry if this has been answered before, but I could only find a topic about it without answers, so here’s my question:

I want to test a new control law to have tests for a paper. How is the best way to do this?

If I understand correctly, the modules mc_att_control and mc_pos_control are the modules that calculate the needed control outputs, while comparing the position/orientation of the drone with the desired setpoint and checking if any parameter has been changed.

Then, some module mixes both outputs and publish the final control vector to actuator_controls_0.

What is the best way to do the same thing for my new control law? Is it just easier to modify these modules and completely replace the original control law?

If I do this, what part of the code should I modify and what part of the code I should absolutely not touch?

Thanks!

Hi, I’m quite a beginner in the PX4 space but had to do something similar and might be able to help you.
For controlling the drones attitude you should look into the mc_rate_control module.
There you can find the implementation of the PID controller that drives the current angular rates to the desired angular rates. Just replacing that piece of code (that calls the PID controller) with your attitude controller should work and then save to att_control.
Note that the mc_att_control only gives the desired angular rates through a quaternion error law, so the controller is not really there, you can check this in the doc.
I haven’t touched the position controller so can’t help you with that.