Files
RDC_Simulation/docs/ardupilot.md

2.0 KiB

ArduPilot SITL Integration

Run the simulation with a realistic ArduPilot flight controller.

Quick Start (2 Terminals)

Terminal 1 - Gazebo:

gz sim -v4 -r ~/ardupilot_gazebo/worlds/iris_runway.sdf

Terminal 2 - SITL + MAVProxy:

sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console

Installation

./setup/install_ardupilot.sh
source ~/.bashrc

This installs:

  • ArduPilot SITL
  • Gazebo Harmonic
  • ardupilot_gazebo plugin
  • MAVProxy

MAVProxy Commands

Once sim_vehicle.py is running:

# Set GUIDED mode
mode guided

# Arm
arm throttle

# Takeoff to 5m
takeoff 5

# Land
mode land

# Disarm
disarm

Available Worlds

# Iris on runway
gz sim -v4 -r ~/ardupilot_gazebo/worlds/iris_runway.sdf

# Zephyr plane
gz sim -v4 -r ~/ardupilot_gazebo/worlds/zephyr_runway.sdf

Standalone SITL (No Gazebo)

sim_vehicle.py -v ArduCopter --console --map

This opens a 2D map view for testing without Gazebo.

How It Works

Gazebo                    ArduPilot SITL
┌─────────────────┐      ┌─────────────────┐
│ iris_runway.sdf │◄────►│ sim_vehicle.py  │
│ + ArduPilot     │ JSON │ + MAVProxy      │
│   Plugin        │ UDP  │                 │
└─────────────────┘      └─────────────────┘
                              │
                              ▼ MAVLink
                         Your Controller

The ArduPilot Gazebo plugin communicates with SITL via JSON over UDP.

Troubleshooting

sim_vehicle.py not found:

export PATH=$PATH:~/ardupilot/Tools/autotest

Plugin not loading:

export GZ_SIM_SYSTEM_PLUGIN_PATH=~/ardupilot_gazebo/build:$GZ_SIM_SYSTEM_PLUGIN_PATH
export GZ_SIM_RESOURCE_PATH=~/ardupilot_gazebo/models:~/ardupilot_gazebo/worlds:$GZ_SIM_RESOURCE_PATH

Can't arm:

# In MAVProxy, disable pre-arm checks
param set ARMING_CHECK 0