Custom Pixhawk Multirotor Attitude Controller


I am looking at making modifications to the stock PX4 attitude controller and have a couple questions regarding the architecture of the mc_att_control module and how it is called. I understand that the attitude controller runs based on the input from the vehicle_attitude_setpoint_s struct, which either comes from the position controller or externally from MAVROS through it’s setpoint_attitude topic. The attitude controller then generates an angular rates setpoint using the vehicle_rate_setpoint_s struct which is sent to the attitude rate controller. The attitude rate controller then generates the variable _att_control which is a 3x1 vector. Is _att_control effectively the desired body torques to be generated by the motors? How is _att_control sent to the “mixer” and the resulting PWMs for the motors generated (is there .cpp file for this)? Is this where the .mix file for the platform comes into play?

At a higher level, if I were to add a custom attitude control module, for example called mc_att_control_custom to the modules folder, how do I specify that I want this controller running instead of the original one? In other words, what is the top layer or code that calls the attitude controller to run?

Any help would be appreciated.

I think you can have a look at the files in ROMFS/px4fmu_common/init.d/rcS or related files.
In these files, each module is started by some shell commands. You can replace mc_att_control by your own module if everything else is fine:)

1 Like


Hi, have you resolved these problems in the blockquote above? If you solve, could you give me doubts? I’m really puzzled by these questions.
Any help would be appreciated.