Run Ardupilot SITL in Docker in Ubuntu LTS 22.04, with SITL and MAVProxy UI using X11/XQuartz display
The quick approach skips setting up UIs and won't use docker-compose, but starts the SITL in one command, as long as Docker Desktop is installed.
docker run -it orthuk/ardupilot-sitl /home/docker/ardupilot/Tools/autotest/sim_vehicle.py -v ArduPlane --frame quadplane --map --console
- Install docker desktop
- Clone repo:
git clone https://github.com/ben-xD/ardupilot-sitl-docker
- Run
cd ardupilot-sitl-docker
- Either:
- Download and run the images I publish:
docker-compose -p sitl up -d remote
- Build a local image:
docker-compose -p sitl up -d local
- Download and run the images I publish:
-
Depending on if you're using locally buit or remote image, use
sitl-remote-1
orsitl-local-1
as the container name -
1 command approach: Run SITL command from outside container:
docker exec -it sitl-local-1 /home/docker/ardupilot/Tools/autotest/sim_vehicle.py -v ArduPlane --frame quadplane --map --console
- Run any command from outside container: run
docker exec -it sitl-local-1 $your_command
- Run any command from outside container: run
-
Enter container approach: Enter container: run
docker exec -it sitl-local-1 bash
- Once inside the container, start SITL: run
sim_vehicle.py -v ArduPlane --frame quadplane --map --console
- Once inside the container, start SITL: run
Pro tip: Read the help pages for sim_vehicle.py (sim-vehicle.help.md
) and MAVProxy (MAVProxy.help.md
).
- Run alongside other GCSs by configuring MAVProxy to output to a port that your GCS listens on: run
docker exec -it sitl-local-1 /home/docker/ardupilot/Tools/autotest/sim_vehicle.py -v ArduPlane --frame quadplane --map --console -w --mavproxy-args="--out udp:host.docker.internal:14550 --state-basedir=/tmp/mavlink-sitl"
- Just install and start QGroundControl. QGroundControl will automatically detect UDP mavlink on 14550.
- You can even connect your SITL to Android mission planner. Find out your android's IP address, and add
--out :udp:$ANDROID_IP_ADDRESS:14550
and launch Mission Planner.
-
Install Xquartz
-
Open Xquarts, go into preferences, Security, and enable "Allow connections from network clients" (credits to https://stackoverflow.com/a/72593701/7365866)
-
Restart your computer
-
In your terminal, run
xhost + 127.0.0.1
. You need to re-run this whenever XQuartz is restarted -
Start SITL: run
docker exec -it sitl-local-1 /home/docker/ardupilot/Tools/autotest/sim_vehicle.py -v ArduPlane --frame quadplane --map --console
You could automatically run by adding the following to your .zshrc
:
# Ardupilot SITL Docker, see https://github.com/ben-xd/ardupilot-sitl-docker
# Allow docker containers to access X11/XQuartz
xhost + 127.0.0.1 >/dev/null 2>&1
- My experience writing Dockerfiles for a few years
- https://github.com/radarku/ardupilot-sitl-docker
- I contributed some changes to it a few years ago (https://github.com/radarku/ardupilot-sitl-docker/commit/ee44adc4f6d57bbddaf911c102cb9ec40e79c683 and https://github.com/radarku/ardupilot-sitl-docker/commit/48cae9d88d8894dcbb6b805c19468a4bc1835877)
- https://ardupilot.org/dev/docs/building-setup-linux.html#building-setup-linux
- https://stackoverflow.com/questions/72586838/xquartz-cant-open-display-mac-os
- https://stackoverflow.com/questions/44429394/x11-forwarding-of-a-gui-app-running-in-docker
- Help pages are saved to
sim_vehicle.README.md
andMAVProxy.README.md
for convenience using:docker exec -it sitl-local-1 /home/docker/ardupilot/Tools/autotest/sim_vehicle.py --help > sim_vehicle.README.md
docker exec -it sitl-local-1 mavproxy.py --help > MAVProxy.README.md
You could consider adding ardupilot to the repo, and copying that in. That will allow you to make changes to Ardupilot and test them on a SITL conveniently.