Ardupilot Simulation (SITL - Simulation In The Loop) allows for safe testing of experimental code and settings and crashing virtual vehicles is a lot cheaper than crashing real ones!
It was written for X11/Linux. Fortunately thanks to Vagrant and XQuartz it can be run on MacOS.
- https://www.xquartz.org/
- https://www.vagrantup.com/downloads.html
- https://www.virtualbox.org/wiki/Downloads
Clone ardupilot and submodules:
git clone --recursive https://github.com/ardupilot/ardupilot
cd ardupilot
If you already develop Ardupilot, you may need to clean out some folders modified within Vagrant:
rm -rf build
Edit Vagrantfile
to setup X11 forwarding:
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.forward_x11 = true
Startup Vagrant/Virtualbox, using the ssh -X
flag (via -- -X
at the end of the command) to enable X11 forwarding:
cd Tools/vagrant
vagrant up
Perhaps the provision step fails; it might not matter. Carry on.
HOST_IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
xhost + $HOST_IP
vagrant ssh -c "sim_vehicle.py -j 2 --console --map --out=$HOST_IP:14550 -v ArduPlane " -- -X
The SITL program should launch on your host machine (MacOS) within XQuartz. XQuartz will be launched for you when you run the xhost
command above.
From your MacOS, you can now access the MAVLink traffic on port 14550.
For example, MAVProxy can connect:
mavproxy.py --master=0.0.0.0:14550
Similarly QGroundControl will immediately picked up the location of the plane from the simulator:
Since it takes a while to run vagrant up
the first time, you might like to use vagrant suspend
to shutdown the VM between uses.
use waf clean or waf distclean instead of rm -rf build .
The provision step shouldn't failed otherwise you will miss something..
don't pass -j 2 as waf will scale itself to available proc in the VM.