Simulink TECS controller: integrator throttle state





Hello,

Been taking on an effort to develop a Simulink blockset which recreates the arduplane control system for use in a flight simulator. The premise is to use mission planner as a command and control system for the simulator via UDP connection.

I’ve managed to find the pictured section of the TECS.ccp which cannot be mathematically recreated in Simulink and would like to see if anyone has deeper insight into the TECS controller.

Using the variables pulled directly from the source code in conjunction with SITL over UDP into simulink, we can observe the variables from the TECS source code. I have found that the previous step of the integrator throttle state when added in a mathematically equivalent loop as the source code results in an integrator throttle state which is not equivalent to the result from the source code itself. However, when adding the previous step (directly from UDP) in a '“feed forward” manner the result is consistent (orange and blue signals in plot).

Observe the simulated loop (yellow line) which is much different resulting from a difference in the previous time step of the integrator throttle state. Nonetheless, after looking through the data exhaustively, the difference added from the previous time step appears to be mathematically correct and I have not been able to successfully recreate the result from the source code as it is written. (Is the source code not functioning correctly???)

Note the integrator throttle state is only defined in the source code which is pictured.

In my throttle controller (not pictured), I have recreated and validated all of the inputs to the throttle integrator calculation and am seeing the same result.

Happy to have a much more in-depth discussion regarding the topic, there is obviously a lot more information than I can feasibly share in this initial posting.

Best,
Brett Erickson

It seems like the UAV Toolbox supports PX4 boards: PX4 Autopilots Support from UAV Toolbox - Hardware Support - MATLAB & Simulink
Have you explored this path? It might allow one way (simulink to Pixhawk) but I think it is worth the try to see if the opposite is also possible.

Thank you for the suggestion! I had not really investigated that in depth but, at this point I am 99% done with writing and validating yaw, pitch, roll, and throttle controller blocks for simulink less this issue.

The purpose of this model is to be hardware ambiguous. Mission planner is only used to issue the navigation commands for the model and the model receives simulated values of the dynamic behavior of the vehicle from within based on the dynamic characterization of the vehicle from a separate CFD analysis. Effectively, I am implementing a robust physics backend to evaluate the flight performance of any well characterized fixed wing vehicle which is controlled using ArduPlane.

You can check out the ArduPilot JSON interface. There is a example for MATLAB and Simulink. JSON interface — Dev documentation

Thanks! No issues with interfacing mission planner and Simulink via UDP, all of that is working perfectly. My issue is only related to the calculation of the Integrator Throttle State, which does not appear to be mathematically correct in the CPP source code.