103 lines
2.0 KiB
Markdown
103 lines
2.0 KiB
Markdown
# ArduPilot SITL Integration
|
|
|
|
Run the simulation with a realistic ArduPilot flight controller.
|
|
|
|
## Quick Start (2 Terminals)
|
|
|
|
**Terminal 1 - Gazebo:**
|
|
```bash
|
|
gz sim -v4 -r ~/ardupilot_gazebo/worlds/iris_runway.sdf
|
|
```
|
|
|
|
**Terminal 2 - SITL + MAVProxy:**
|
|
```bash
|
|
sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console
|
|
```
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
./setup/install_ardupilot.sh
|
|
source ~/.bashrc
|
|
```
|
|
|
|
This installs:
|
|
- ArduPilot SITL
|
|
- Gazebo Harmonic
|
|
- ardupilot_gazebo plugin
|
|
- MAVProxy
|
|
|
|
## MAVProxy Commands
|
|
|
|
Once `sim_vehicle.py` is running:
|
|
|
|
```bash
|
|
# Set GUIDED mode
|
|
mode guided
|
|
|
|
# Arm
|
|
arm throttle
|
|
|
|
# Takeoff to 5m
|
|
takeoff 5
|
|
|
|
# Land
|
|
mode land
|
|
|
|
# Disarm
|
|
disarm
|
|
```
|
|
|
|
## Available Worlds
|
|
|
|
```bash
|
|
# 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)
|
|
|
|
```bash
|
|
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:**
|
|
```bash
|
|
export PATH=$PATH:~/ardupilot/Tools/autotest
|
|
```
|
|
|
|
**Plugin not loading:**
|
|
```bash
|
|
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:**
|
|
```bash
|
|
# In MAVProxy, disable pre-arm checks
|
|
param set ARMING_CHECK 0
|
|
```
|