Over the summer I have been working away adding various features to ArduPilot to improve connectivity with MATLAB and Simulink. I will give a brief overview of the features added over the course of the project.
JSON SITL backend
Firstly, a simple JSON format interface was developed, this gives an easy to implement and expand format for physics models to talk to ArduPilot. Although this was originally developed with MATLAB in mind this is now also used by the Pybullet interface along with other simulators in development.
MATLAB vehicle physics example
This allows one to write a physics backend in MATLAB and fly it with ArduPilot using the new JSON format. Custom vehicle dynamics can be added to support new vehicle types or to model existing types in more detail. The user only needs calculate the forces and moments the motors/wing/wheels/rudder/legs ect produce, the dynamics and connection are done by the provided connection function. A copter example has been made, it will happily fly with the EKF running, this is a good sign that the physics is correct and the is simulator working in sync with ArduPilot.
Simulink example
A Simulink rover and helicopter model have also been added. The rover example is very basic; however, the helicopter model is very detailed (Thanks Bill!).
Streaming and displaying Data
MATLAB can also be used as a powerful visualisation tool allowing the developer to see what is going on inside the code in real-time. This insight can help quickly track down bugs and help understand behaviors. Thanks to the UDP connection tools implemented for the physics backend this is quick and easy to setup.
Interfacing with serial ports
Again, thanks to the connection tools implemented for the physics backend it is now posible to quickly develop code that interfaces with SITL serial ports. This can be used to debug new drivers and provide known readings for testing SITL.
Autotune
MATLAB was also used to prototype a new methodology for AutoTune. Although this work is not yet finished it is hoped that it will bring a autotune to new vehicle types in the future.
Wiki
Instructions on how to use MALTAB and Simulink with ArduPilot can be found on the Wiki.
https://ardupilot.org/dev/docs/sitl-with-MATLAB.html
Pull Requests
This GSoC project has generated lots of pull requests, Iβm pleased to say most of these have now been merged into the main ArduPilot repository.
It only remains to thank the ArduPilot dev team for giving me the opportunity to participate in GSoC again this year.
In particular I would like to thank @tridge and @bnsgeyer my GSoC mentors for there support and advice.