Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

ArduPilot SITL on Windows (WSL) — Beginner‑Friendly Guide

Spin up a full ArduPilot Software‑In‑The‑Loop (SITL) drone simulator on a Windows laptop using WSL (Ubuntu). This guide is copy‑paste friendly and includes tips for Mission Planner / QGroundControl and DroneKit.

Works great on Windows 11 (WSLg GUI supported). On Windows 10, either use an X‑server (VcXsrv) for GUI windows or run without --map --console and connect from a Windows GCS.


✅ What you’ll get

  • A compiled ArduCopter SITL binary
  • One‑command run via sim_vehicle.py with map + console
  • GCS connection (Mission Planner / QGroundControl)
  • Optional DroneKit connection

Prerequisites

  • Windows 10/11 64‑bit
  • ~10 GB free disk space
  • Admin access
  • Stable internet

1) Install WSL + Ubuntu (once)

Open PowerShell as Administrator and run:

wsl --install

Reboot if prompted, then launch Ubuntu from the Start menu and create your Linux username (e.g., ace).

Already have WSL? Ensure WSL 2 is default:

wsl --set-default-version 2

2) Prepare Ubuntu (packages & tools)

In the Ubuntu terminal:

sudo apt update && sudo apt upgrade -y
# Common build + Python tools
sudo apt install -y git python3 python3-pip python3-dev python3-setuptools \
  build-essential cmake g++ \
  libxml2-dev libxslt1-dev \
  python3-opencv python3-matplotlib \
  python3-tk

python3-tk enables MAVProxy's optional map/console windows. On Windows 11 WSLg, these pop up natively. On Windows 10, use an X‑server or run headless.


3) Get ArduPilot source

cd ~
git clone https://github.com/ArduPilot/ardupilot.git
cd ardupilot
git submodule update --init --recursive

4) Install ArduPilot prerequisites

ArduPilot ships a helper script for Ubuntu:

Tools/environment_install/install-prereqs-ubuntu.sh -y
# Reload environment
. ~/.profile

5) Configure & build SITL (from repo root)

Important: Run ./waf ... from the top‑level ardupilot folder — not inside ArduCopter/.

cd ~/ardupilot
./waf configure --board sitl
./waf copter
  • To build other vehicles later:
    ./waf plane    # ArduPlane
    ./waf rover    # Rover
    ./waf sub      # Submarine

6) Run SITL

Start a quadcopter with console and map:

cd ~/ardupilot
Tools/autotest/sim_vehicle.py -v ArduCopter -f quad --console --map

You should see MAVProxy console output and a map. The vehicle will boot on the runway at a default location.

Useful switches

# Faster sim time
--speedup 1            # 1 = realtime (increase for faster‑than‑real‑time)

# Change home
--lat <deg> --lon <deg> --alt <m>

# Multiple vehicles
-N                      # auto‑increment ports for additional instances

7) Connect a Ground Control Station (GCS)

Mission Planner (Windows)

  1. Launch SITL first.
  2. Open Mission PlannerCONNECT → choose UDP → port 14550Connect.
  3. It should auto‑discover. If not, start SITL with an explicit output:
    Tools/autotest/sim_vehicle.py -v ArduCopter -f quad --console --map \
      --out=udp:127.0.0.1:14550

QGroundControl (Windows/Mac/Linux)

  • Start SITL; QGC usually auto‑connects to UDP 14550.

MAVProxy (built‑in console)

From the MAVProxy console you can try:

mode GUIDED
arm throttle
takeoff 10

8) Connect with DroneKit (optional)

Minimal example (Python):

from dronekit import connect, VehicleMode

# UDP endpoint commonly used by SITL
vehicle = connect('127.0.0.1:14550', wait_ready=True)

print("Connected:", vehicle.version)
vehicle.mode = VehicleMode("GUIDED")
vehicle.armed = True
vehicle.flush()

# ... write mission / takeoff logic here ...

vehicle.close()

If you prefer TCP, use connect('tcp:127.0.0.1:5760', wait_ready=True) depending on your sim_vehicle.py outputs.

Install DroneKit in WSL Ubuntu:

python3 -m pip install --upgrade pip
pip install dronekit pymavlink

Quick Start — Copy/Paste

# 0) In Ubuntu (WSL)
sudo apt update && sudo apt upgrade -y
sudo apt install -y git python3 python3-pip python3-dev python3-setuptools \
  build-essential cmake g++ libxml2-dev libxslt1-dev python3-opencv \
  python3-matplotlib python3-tk

cd ~ && git clone https://github.com/ArduPilot/ardupilot.git
cd ardupilot && git submodule update --init --recursive
Tools/environment_install/install-prereqs-ubuntu.sh -y
. ~/.profile

./waf configure --board sitl
./waf copter

Tools/autotest/sim_vehicle.py -v ArduCopter -f quad --console --map

Common Troubleshooting

1) No function 'configure' defined in .../ArduCopter/wscript
You ran ./waf inside ArduCopter/. Run from repo root:

cd ~/ardupilot
./waf configure --board sitl
./waf copter

2) No function 'copter' defined in .../ArduCopter/wscript
Same root cause—run from repo root (~/ardupilot), not inside ArduCopter/.

3) waf-light: error: no such option: --board
You’re on an older branch. Either git pull to update, or use the older syntax:

./waf configure --target=bin/arducopter
./waf build --target=bin/arducopter

Then run:

Tools/autotest/sim_vehicle.py -v ArduCopter -f quad --console --map

4) sim_vehicle.py: command not found
Use the full path: Tools/autotest/sim_vehicle.py ...
(Optionally add export PATH="$HOME/ardupilot/Tools/autotest:$PATH" to ~/.bashrc.)

5) No GUI map/console on WSL

  • Windows 11: ensure you’re on WSLg (default for wsl --install).
  • Windows 10: install an X‑server (e.g., VcXsrv) and set export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0 before running, or omit --map --console and use a Windows GCS.

6) GCS doesn’t connect

  • Open Mission Planner first, choose UDP 14550.
  • Or start SITL with: --out=udp:127.0.0.1:14550.
  • Ensure no firewall blocks UDP 14550.

7) Clean rebuild

./waf clean
./waf copter

Updating Later

cd ~/ardupilot
git pull
git submodule update --init --recursive
./waf configure --board sitl
./waf copter

Next Steps

  • Try Auto missions from Mission Planner / QGC
  • Simulate GPS glitches / wind / failsafes
  • Explore Gazebo or SITL‑with‑AirSim for 3D worlds
  • Hook up your GCS web app / DroneKit scripts

License & Credits

  • ArduPilot is GPLv3 — see the upstream repository for full license and docs.
  • Huge thanks to the ArduPilot community and maintainers.

Happy flying (virtually)! 🚁

About

This repo holds the steps and setup on how to run Ardupilot using SITL in Windows (WSL)

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Contributors