Files
RDC_Simulation/docs/ardupilot.md
2026-01-04 02:31:31 +00:00

2.4 KiB

ArduPilot GPS-Denied Simulation

Realistic flight controller simulation with your drone logic.

Quick Start (2 Terminals)

Terminal 1 - Gazebo:

./scripts/run_ardupilot_sim.sh runway
# Options: runway, warehouse, zephyr

Terminal 2 - Controller + SITL:

./scripts/run_ardupilot_controller.sh

How It Works

The run_ardupilot_controller.sh script starts ArduPilot SITL in the background and connects your controller to it via MAVLink.

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│ Gazebo          │◄───►│ ArduPilot SITL  │◄───►│ run_ardupilot.py│
│ (Physics)       │JSON │ (Hidden)        │MAV  │ (Your Logic)    │
└─────────────────┘     └─────────────────┘     └─────────────────┘
                                                        │
                                                        ▼
                                               drone_controller.py

Manual Mode (Debugging)

If you need to debug with MAVProxy console (3 Terminals):

Terminal 1:

./scripts/run_ardupilot_sim.sh runway

Terminal 2:

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

Terminal 3:

# Debug commands in MAVProxy:
param set ARMING_CHECK 0
mode guided
arm throttle force

Installation

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

Configuration

Your drone_controller.py receives telemetry and returns control inputs.

The simulation translates your inputs:

  • thrust → Vertical velocity
  • pitch/roll → Horizontal velocity
  • yaw → Yaw rate

Troubleshooting

"SITL failed to start"

Check if sim_vehicle.py is in your PATH:

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

Drone drift

ArduPilot in GUIDED mode requires good position estimation. Without GPS, it relies on optical flow or visual odometry (not yet implemented in default setup). The drone might drift if relying only on IMU.

"No JSON sensor message"

Ensure Gazebo (Terminal 1) is running before starting the controller.

Visualizing Camera

python camera_viewer.py --topic /drone/camera

(Requires bridging the topic if using ROS 2 bridge)