The primary purpose of this repository is to provide a SITL (Software-in-the-Loop) simulator for an ArduPilot-powered flight controller like the Cube Orange, for use in other projects.
The Docker image contains the ArduPilot SITL environment integrated with Gazebo Harmonic for realistic physics-based simulation.
You can pull the pre-built image directly from GitHub Container Registry:
docker pull ghcr.io/wkronmiller/flight-controller-sim:masterThis Docker image is designed to provide a complete and ready-to-use ArduPilot SITL simulation environment.
- Base Image: Built on
ghcr.io/wkronmiller/ardupilot:master. - ArduPilot Vehicles: Includes SITL executables for
Copter,Plane, andRover, compiled for thesitlboard. - Gazebo Integration: Comes with the ArduPilot Gazebo plugin pre-built for Gazebo Harmonic. It uses a JSON interface for communication between ArduPilot and Gazebo.
- Process Management: Uses
supervisordto run the SITL process, with the default configuration set to launch the Rover simulation. - Networking: The
compose.ymlis configured withnetwork_mode: hostto simplify connections with a GCS and a Gazebo instance running on the host or local network.
The recommended way to run the simulator is with Docker Compose, as it uses the settings defined in compose.yml.
-
Start the Simulator:
docker-compose up
If you haven't built the image locally, compose will pull it from the registry. This will start the simulator in the foreground. The
supervisord.conffile is configured to start the Rover simulation by default with Gazebo integration enabled (-f gazebo-rover --model JSON). -
Build Locally (Optional): If you need to make changes to the
Dockerfileor configuration, you can build the image locally:docker-compose build
If you prefer not to use Docker Compose, you can run the image directly. Using host networking is crucial for communication with Gazebo and your GCS.
docker run --rm -it --network=host ghcr.io/wkronmiller/flight-controller-sim:masterThis container is designed to work with a Gazebo instance running Gazebo Harmonic. The integration includes:
- ArduPilot Gazebo Plugin: Pre-built and configured for seamless communication.
- Physics Simulation: Realistic vehicle dynamics through Gazebo's physics engine.
- Install Gazebo Harmonic on your host system or another machine.
- Download ArduPilot Gazebo Models:
git clone https://github.com/ArduPilot/ardupilot_gazebo export GZ_SIM_RESOURCE_PATH=$GZ_SIM_RESOURCE_PATH:$(pwd)/ardupilot_gazebo/models:$(pwd)/ardupilot_gazebo/worlds
- Launch Gazebo with an ArduPilot-compatible world:
gz sim -v4 -r iris_runway.sdf
Once the container is running, the ArduPilot SITL instance will be waiting for connections.
- Protocol: UDP
- Host:
localhost(or the host IP if running Docker on a different machine) - Port:
14550
You can use a GCS like QGroundControl or Mission Planner to connect to the running simulation.
The simulator automatically attempts to connect to a running Gazebo instance using:
- Protocol: JSON over UDP
- Port:
14551(for internal communication to Gazebo)
- Start Gazebo with an ArduPilot world.
- Launch this Docker container using
docker-compose upordocker run. - Connect your GCS to
localhost:14550. - The vehicle in Gazebo will respond to commands from your GCS with realistic physics.
This simulator is configured to run ArduPilot Rover by default, but it can be adapted to run other vehicle types like Copter or Plane.
-
Verify the Build Target in
Dockerfile: TheDockerfilealready compilesrover,copter, andplane. If you need another vehicle, you'll have to add it to the build steps.# ... RUN --mount=type=cache,target=/home/ardupilot/.ccache \ ./modules/waf/waf-light configure --board sitl \ && ./modules/waf/waf-light rover \ && ./modules/waf/waf-light copter \ && ./modules/waf/waf-light plane # ...
-
Update
supervisord.conf: Modify thesupervisord.conffile to launch your desired vehicle. For example, to switch from Rover to Copter, you would change the[program:rover]section.Example for Copter with Gazebo:
[program:copter] command=bash -c "/ardupilot/source/Tools/autotest/sim_vehicle.py --vehicle=Copter --frame=gazebo-iris --console --out=0.0.0.0:14550 --no-mavproxy --no-rebuild --out=udp:127.0.0.1:14551 -f gazebo-iris --model JSON" autostart=true autorestart=true stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/tmp/Copter.log user=ardupilot
-
Rebuild and Run: After modifying the configuration, rebuild the Docker image and restart the container:
docker-compose build docker-compose up
- Ensure Gazebo is running before starting the container.
- Check that the Gazebo world contains ArduPilot-compatible models.
- Verify network connectivity if running Gazebo on a remote machine.
- Check container logs for JSON communication errors.
The container sets the following Gazebo-related environment variables:
GZ_VERSION=harmonic: Specifies Gazebo Harmonic version.GZ_SIM_SYSTEM_PLUGIN_PATH=/ardupilot/plugin/build: Path to ArduPilot Gazebo plugin.HEADLESS=1: Runs in headless mode (no GUI).