SITL runs the ArduPilot firmware from the flight controller on your computer. You test your mission code without flying a drone and spot crash risks at your desk. The commands are the same ones we use in our blog posts and courses.
Choose your path
No install needed
In the browser
Nothing to install on your computer: Python, pymavlink, MAVProxy and SITL come ready. It uses your GitHub account's free allowance.
You don't need to compile ArduPilot to test your Python code and your Mission Planner connection. The code in our blog posts runs on this setup. The same commands work in Ubuntu on WSL and on a virtual machine.
Download the files
The Linux SITL binary of the stable Copter release and the default parameters:
-I0 is the instance number and sets the ports. --home gives the home point as latitude, longitude, altitude and heading. --speedup 1 runs the simulation in real time; you need it if you're going to measure message rates in Hz.
When you see the Waiting for connection .... line in the terminal, the vehicle is waiting for its first client. Leave this terminal open.
Install pymavlink for Python
In a separate terminal, install pymavlink in a virtual environment. Your mission code connects to tcp:127.0.0.1:5760.
Choose TCP as the connection type, enter 127.0.0.1 as the address and 5762 as the port. While your mission code is using 5760, don't point Mission Planner at the same port: SITL accepts only one client per port at a time.
Full development environment: sim_vehicle.py and MAVProxy
If you want the map, the MAVProxy console, plane and VTOL airframes or the Gazebo plugin, install ArduPilot from source. This is the route the AI and Drone Simulation course takes.
According to ArduPilot's documentation, this script doesn't work on Ubuntu releases past the end of standard support; the docs give 20.04 as an example. For a new install, pick an LTS release that's still supported. If you've upgraded Ubuntu, run the script again.
Start the simulation
On the first run, -w wipes the saved parameters and loads the defaults:
Shell
cd ~/ardupilot/ArduCoptersim_vehicle.py--console--map-w
You need Windows 10 version 2004 or later, or Windows 11. Mission Planner runs on Windows, and SITL runs in Ubuntu inside WSL.
Install WSL and Ubuntu
Open PowerShell as administrator. The command enables WSL and installs Ubuntu. When it's done, restart the computer, open Ubuntu and set a username and password.
Shell
wsl--install
Follow the Ubuntu steps inside WSL
Quick setup or full environment, the commands are the same. Clone the ArduPilot repository into WSL's own file system (e.g. ~/ardupilot), not into Windows folders. Builds are much faster that way.
On Windows 11 the map and console windows open on their own. On Windows 10, install an X server such as VcXsrv and start it with the "Start no Client" and "Disable access control" options.
Connect Mission Planner
Shell
cd ~/ardupilot/ArduCopter../Tools/autotest/sim_vehicle.py--map--console
Start Mission Planner once the MAVProxy console and map are open. It usually connects by itself. If it doesn't, choose UDP and connect to 14550. If you've turned on WSL2's "mirrored" networking mode, add --no-wsl2-network to the command.
By default WSL2 doesn't see USB, so you can't connect the flight controller from inside WSL. When working with the board, use Mission Planner on Windows.
Windows: installing with a virtual machine
In the course we install Ubuntu inside VMware. The virtual disk needs at least 20 GB of free space; we recommend 50 GB.
Set up the virtual machine
Install VMware, install Ubuntu in the virtual machine, then follow the Ubuntu steps above inside it.
If you'd rather skip the setup, the ready-made virtual machine copy comes with ArduPilot SITL, Gazebo 11, ROS Noetic, DroneKit and pymavlink installed on Ubuntu 20.04.
Connect Mission Planner on the host machine
SITL's TCP ports listen on every network interface, not just 127.0.0.1. If networking is in bridged mode, open a TCP connection from Mission Planner straight to the virtual machine's address (5760, or 5762 if that one's free). Find the address on the virtual machine:
Shell
hostname-I
If you're using sim_vehicle.py, add UDP 14550 to the Windows address in MAVProxy with output add.