Servers by jDrones

HIL or SITL with Matlab


(palframan) #1

I would like to set up a HIL or SITL with Matlab simulation the airplane equations of motion in order to test a python script to be executed on a Pixhawk board. Any help in getting started would be greatly appreciated!

Previous experience:
I have previously set up a HIL sim with X-plane and an APM board, but nothing using the Pixhawk.

What I know:
I know the current version of arduplane won’t support HIL sims, I also know that HIL sims may be prohibitively slow, so SITL may be preferential, although I have zero experience with SITL.

What I’d like to know:

  1. What version of arduplane should I be using?
  2. The code i’m testing is going to be a low level controller, can HIL handle this, or should I be attempting SITL?
  3. are the required serial outputs and inputs listed somewhere so that I know what Matlab will be taking in / putting out?
  4. Do I need to modify the arduplane code in any way other than the HIL_MODE line?
  5. Any other resources to help get me started?

(ed1992) #2

I am interested in a similar project and was wondering if anyone could provide some source code / simulation for matlab or simulink for the Arduplane controller. I found a good description of the various controllers on the wiki, plane.ardupilot.com/wiki/roll-pi … er-tuning/ but was hoping for additional controller code and implementation information.


(bmb000) #3

I am working with a team at NASA Ames that just open sourced a toolbox that allows for easy control of X-Plane simulations or visualizations using UDP.

We have added example scripts to control X-plane simulations or visualizations from C and Matlab, (working on adding Java and python). With this tool you can easily test out your own control algorithms in Matlab or C, and you can do HIL/SIL testing with control algorithms running on the ArduPilot (You just need to use a tool like APM Planner to communicate with the ArduPilot over UDP)

Check it out on github. https://github.com/bmb000/XPlaneConnect.git


(bmb000) #4

Sorry I posted the link to my forked repository. Find the X-Plane connect toolbox at:
github.com/nasa/XPlaneConnect.git

[quote=“bmb000”]I am working with a team at NASA Ames that just open sourced a toolbox that allows for easy control of X-Plane simulations or visualizations using UDP.

We have added example scripts to control X-plane simulations or visualizations from C and Matlab, (working on adding Java and python). With this tool you can easily test out your own control algorithms in Matlab or C, and you can do HIL/SIL testing with control algorithms running on the ArduPilot (You just need to use a tool like APM Planner to communicate with the ArduPilot over UDP)

Check it out on github. https://github.com/bmb000/XPlaneConnect.git[/quote]


(Martin) #5

Hello,I am working on model of a VTOL UAV in Matlab / Simulink as a part of my diploma thesis. I would like to connect Simulink FDM with ArduPilot (SITL and then maybe HIL).
I ran SITL with sim_vehicle.py FDM. Also I ran ArduPlane.elf, and it is writing “Waiting for connection…” but I didn’t find any description how to connect it.
Does anybody have any experience with connecting ArduPilot SITL with Matlab?
There must be some SITL API, isn’t it? Is there any description of it?
Thank you for any advice.