Simulating new aircraft configuration

Dear srs.,

I am currently working with simulation and control of aircraft, and I have accomplished some results in MATLAB. I only recently became aware of Ardupilot and became curious about it. I would like to know if I could get aerodynamical data (for instance, from CFD simulation or DATCOM) and insert this data directly into Ardupilot to simulate my own aircraft. Is there a tutorial on how to alternate the code for this purpose? Also, for the controllers. Would there be a way to test my own controller code? Thank you very much.


Hey there, welcome to the Ardupilot forums!

What you’re asking is certainly doable, but I haven’t done so myself. However, you can use Ardupilot’s SITL with a Matlab model. Essentially, Matlab will run the dynamics while the SITL runs in the background.

Here is a few readmes:

Ardupilot’s SITL sends the PWM commands to MATLAB over IP using a JSON packaging, MATLAB simulates the dynamics and then sends back the new states to the SITL. And you can modify the dynamic model to your liking, as long as you send back the correct states to the SITL.

I’ve done this a few times, so feel free to ask questions if you need help!

You of course have to set up the SITL environment. I’ve set it up using WSL, to be able to run it in Windows and to have Matlab on the same computer.

As for a custom controller, it also is certainly doable, but I can’t guide you with that. But yes, you can download Ardupilot’s source code, modify it and compile it (either for a specific flight controller board or for SITL).