Custom attitude controller thrust computation

Hello,

I am working on my Master’s thesis, where I have designed a custom attitude controller for a multirotor, and I am currently testing it on a Pixhawk using ArduPilot.

I have successfully integrated my controller using the AC_CustomControl framework and flashed it into ArduCopter. My controller is model-based and outputs desired roll, pitch, and yaw torques in physical units (N·m).

Before sending these commands to the mixer, I would like to normalize the torque commands based on the available thrust margin. To do this correctly, I need access to the commanded thrust (or commanded acceleration) produced by the position controller, since this determines the physical headroom available for roll, pitch, and yaw.

My main questions are:

  1. In the ArduPilot firmware architecture, how can I access the commanded thrust, acceleration, or normalized thrust computed by the position controller from within my AC_CustomControl.cpp file?
    (I assume this would involve modifying AC_CustomControl_XYZ.cpp, following the custom controller tutorial.)

  2. More generally, what is the recommended way to expose or pass internal outputs from one module (e.g., position control) to another module (e.g., attitude or rate control) in ArduPilot, without breaking the existing architecture?

Any guidance on the correct design approach or existing patterns within ArduPilot would be greatly appreciated.

Thank you.