How to replace mc_att/rate_control and other modules for quadrocopter?

Hi All,

I have PX4 2.8.4

I would like to replace the modules that make control for quadrotor (I would like to try LQR).
I understand that it should replace one of the modules mc_att_control or mc_rate_control (which one?). I need ekf2 and rc as inputs, and will have motor values as outputs.

But I don’t understand, in which format actuators are working and what is actuators?
For example in mc_rate_control I see:
actuators.control[actuator_controls_s::INDEX_ROLL] = PX4_ISFINITE(att_control(0)) ? att_control(0) : 0.0f;

Then, as I understand, this actuators.control[…] will go to the mixer.
I don’t understand, how the yaw, pitch, rol and throtle converted to the ESC motor values?

Can someone help me this this here?

Thanks,
Dmitry

Are you willing to share the code if you are successful?

You mean you want to use ekf2 and rc as input, and use motor speed as output instead of going through the mixer, right?

If so,The output of the current angular velocity controller is mixed here and finally output to esc

As for which module to replace, it depends on which loop you use lqr control.If you plan to use the lqr algorithm in angular velocity control, then just replacing/modifying mc_rate_control is enough

Hi Xdwgood,

Yes, I plan to publish.

I have check and this code is not affected by the PWM output. I have check MultirotorMixer and other mixers and did not found the place, where the controls.control[…] converted to the motor output values…
I see, that in
PX4IO::io_set_control_state(unsigned group)
… for (unsigned i = 0; (i < _max_controls) && (i < sizeof(controls.control) / sizeof(controls.control[0])); i++) {
/* ensure FLOAT_TO_REG does not produce an integer overflow */

we copy control values to the px4io controller.
The MultirotorMixer or other mixer should be executed there, but it’s not.
I just need to know the law for transformation between controls.control and real ESC outputs. :slight_smile: