ArduPilot SITL Update
This commit is contained in:
@@ -1,176 +1,94 @@
|
||||
# Architecture Overview
|
||||
|
||||
GPS-denied drone landing simulation with multiple operation modes.
|
||||
|
||||
## Operation Modes
|
||||
|
||||
### 1. Standalone Mode (Any Platform)
|
||||
### 1. Standalone (Any Platform)
|
||||
|
||||
Single-process simulation - no ROS 2 or networking required:
|
||||
Single process, no ROS 2 required:
|
||||
|
||||
```bash
|
||||
python standalone_simulation.py --pattern circular
|
||||
```
|
||||
|
||||
```
|
||||
┌────────────────────────────────────────┐
|
||||
│ standalone_simulation.py │
|
||||
│ ┌──────────────────────────────────┐ │
|
||||
│ │ PyBullet Physics + Camera │ │
|
||||
│ │ Built-in Landing Controller │ │
|
||||
│ │ Rover Movement Patterns │ │
|
||||
│ │ Configuration from config.py │ │
|
||||
│ │ Built-in Controller │ │
|
||||
│ │ Rover Movement │ │
|
||||
│ └──────────────────────────────────┘ │
|
||||
└────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 2. PyBullet + ROS 2 Mode (Two Terminals)
|
||||
### 2. Gazebo + ROS 2 (2 Terminals)
|
||||
|
||||
**Terminal 1:**
|
||||
```bash
|
||||
ros2 launch gazebo/launch/drone_landing.launch.py
|
||||
```
|
||||
|
||||
**Terminal 2:**
|
||||
```bash
|
||||
python run_gazebo.py --pattern circular
|
||||
```
|
||||
|
||||
```
|
||||
Terminal 1 Terminal 2
|
||||
┌──────────────────┐ ┌──────────────────────────┐
|
||||
│ simulation_host │◄─UDP───►│ run_bridge.py │
|
||||
│ (PyBullet) │ │ ┌────────────────────┐ │
|
||||
│ Port 5555 │ │ │ ROS2SimulatorBridge│ │
|
||||
│ │ │ │ DroneController │ │
|
||||
│ │ │ │ RoverController │ │
|
||||
└──────────────────┘ │ └────────────────────┘ │
|
||||
└──────────────────────────┘
|
||||
┌───────────────────┐ ┌───────────────────┐
|
||||
│ Gazebo + Bridge │◄──────►│ run_gazebo.py │
|
||||
│ (Physics) │ ROS │ + Controllers │
|
||||
└───────────────────┘ └───────────────────┘
|
||||
```
|
||||
|
||||
Data flow:
|
||||
- RoverController publishes position → Bridge sends to Simulator
|
||||
- Simulator moves rover visually AND sends back telemetry
|
||||
- DroneController receives telemetry, publishes commands
|
||||
- Bridge forwards commands to Simulator
|
||||
### 3. ArduPilot SITL (2 Terminals)
|
||||
|
||||
### 3. Gazebo + ROS 2 Mode (Two Terminals, Linux/WSL2)
|
||||
|
||||
```
|
||||
Terminal 1 Terminal 2
|
||||
┌───────────────────────────┐ ┌──────────────────────────┐
|
||||
│ ros2 launch ... .launch.py│ │ run_gazebo.py │
|
||||
│ ┌─────────────────────┐ │ │ ┌────────────────────┐ │
|
||||
│ │ Gazebo (ign gazebo) │ │ │ │ GazeboBridge │ │
|
||||
│ │ - Drone (vel ctrl) │ │◄────►│ │ DroneController │ │
|
||||
│ │ - Rover (vel ctrl) │ │ ROS │ │ RoverController │ │
|
||||
│ ├─────────────────────┤ │ │ └────────────────────┘ │
|
||||
│ │ ros_gz_bridge │ │ └──────────────────────────┘
|
||||
│ └─────────────────────┘ │
|
||||
└───────────────────────────┘
|
||||
**Terminal 1:**
|
||||
```bash
|
||||
ros2 launch ardupilot_gz_bringup iris_runway.launch.py
|
||||
```
|
||||
|
||||
Data flow:
|
||||
- RoverController publishes to `/rover/cmd_vel` → Gazebo moves rover
|
||||
- Gazebo publishes odometry → GazeboBridge converts to telemetry
|
||||
- DroneController receives telemetry, publishes to `/cmd_vel`
|
||||
- GazeboBridge forwards to `/drone/cmd_vel` → Gazebo moves drone
|
||||
|
||||
### 4. ArduPilot SITL + Gazebo Mode (Three Terminals, Linux/WSL2)
|
||||
|
||||
```
|
||||
Terminal 1 Terminal 2 Terminal 3
|
||||
┌──────────────┐ ┌─────────────────┐ ┌────────────────────────┐
|
||||
│ Gazebo + │ │ ArduPilot SITL │ │ run_ardupilot.py │
|
||||
│ ArduPilot │◄──►│ sim_vehicle.py │ │ ┌──────────────────┐ │
|
||||
│ Plugin │JSON│ + MAVProxy │◄───►│ │ MAVLinkBridge │ │
|
||||
│ │ │ │ UDP │ │ DroneController │ │
|
||||
│ ardupilot_ │ │ Flight Control │ │ │ RoverController │ │
|
||||
│ drone.sdf │ │ + GCS │ │ └──────────────────┘ │
|
||||
└──────────────┘ └─────────────────┘ └────────────────────────┘
|
||||
**Terminal 2:**
|
||||
```bash
|
||||
mavproxy.py --console --map --master=:14550
|
||||
```
|
||||
|
||||
Data flow:
|
||||
- ArduPilot SITL sends motor commands → Gazebo plugin controls drone
|
||||
- Gazebo plugin sends sensor data → ArduPilot SITL for state estimation
|
||||
- MAVProxy outputs telemetry → MAVLinkBridge converts to ROS telemetry
|
||||
- DroneController receives telemetry, publishes velocity commands
|
||||
- MAVLinkBridge sends MAVLink commands → ArduPilot SITL executes
|
||||
```
|
||||
┌─────────────────────────────────────────────┐
|
||||
│ Single Launch Command │
|
||||
│ (Starts SITL + Gazebo + RViz) │
|
||||
├─────────────────────────────────────────────┤
|
||||
│ ArduPilot SITL ◄──► Gazebo ◄──► ROS 2 │
|
||||
│ ▲ │
|
||||
│ │ /ap/* topics │
|
||||
│ ▼ │
|
||||
│ MAVProxy (GCS) │
|
||||
└─────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
Key differences from simple Gazebo mode:
|
||||
- Full ArduPilot flight controller (EKF, stabilization, failsafes)
|
||||
- Real MAVLink protocol for commands and telemetry
|
||||
- Support for all ArduPilot flight modes (GUIDED, LAND, etc.)
|
||||
- Arming checks and safety features
|
||||
- Compatible with ground control stations (QGroundControl, Mission Planner)
|
||||
## Key Components
|
||||
|
||||
## Components
|
||||
|
||||
| File | Description |
|
||||
|------|-------------|
|
||||
| `config.py` | Central configuration (positions, physics, gains) |
|
||||
| `standalone_simulation.py` | All-in-one simulation |
|
||||
| `simulation_host.py` | PyBullet physics server (UDP) |
|
||||
| `run_bridge.py` | PyBullet bridge + controllers |
|
||||
| `run_gazebo.py` | Gazebo bridge + controllers |
|
||||
| `run_ardupilot.py` | **ArduPilot SITL** + MAVLink bridge |
|
||||
| `mavlink_bridge.py` | MAVLink ↔ ROS 2 bridge |
|
||||
| `drone_controller.py` | **Your landing algorithm** |
|
||||
| `rover_controller.py` | Moving landing pad |
|
||||
| `ros_bridge.py` | ROS-UDP bridge (used by run_bridge.py) |
|
||||
| `gazebo_bridge.py` | Gazebo-ROS bridge (used by run_gazebo.py) |
|
||||
| `gazebo/launch/drone_landing.launch.py` | ROS 2 launch file for Gazebo |
|
||||
| `gazebo/launch/ardupilot_drone.launch.py` | ROS 2 launch file for ArduPilot |
|
||||
| `gazebo/worlds/drone_landing.sdf` | Gazebo world with simple velocity control |
|
||||
| `gazebo/worlds/ardupilot_drone.sdf` | Gazebo world with ArduPilot plugin |
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `drone_controller.py` | Your landing algorithm |
|
||||
| `gazebo_bridge.py` | Gazebo ↔ ROS bridge |
|
||||
| `mavlink_bridge.py` | MAVLink commands |
|
||||
| `camera_viewer.py` | Camera display |
|
||||
|
||||
## ROS 2 Topics
|
||||
|
||||
| Topic | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `/cmd_vel` | `Twist` | Drone commands from DroneController |
|
||||
| `/drone/cmd_vel` | `Twist` | Drone commands to Gazebo |
|
||||
| `/drone/telemetry` | `String` | GPS-denied sensor data (JSON) |
|
||||
| `/rover/cmd_vel` | `Twist` | Rover velocity to simulator |
|
||||
| `/rover/telemetry` | `String` | Rover position (JSON) |
|
||||
| Topic | Direction | Description |
|
||||
|-------|-----------|-------------|
|
||||
| `/drone/telemetry` | ← | Sensor data (JSON) |
|
||||
| `/cmd_vel` | → | Velocity commands |
|
||||
| `/drone/camera` | ← | Camera images |
|
||||
| `/rover/telemetry` | ← | Landing pad position |
|
||||
|
||||
## Network Configuration
|
||||
## ArduPilot Topics
|
||||
|
||||
All components default to `0.0.0.0` for network accessibility.
|
||||
|
||||
### Remote Setup (PyBullet mode)
|
||||
|
||||
**Machine 1 (with display):**
|
||||
```bash
|
||||
python simulation_host.py # Listens on 0.0.0.0:5555
|
||||
```
|
||||
|
||||
**Machine 2 (headless controller):**
|
||||
```bash
|
||||
python run_bridge.py --host 192.168.1.100
|
||||
```
|
||||
|
||||
### UDP Ports
|
||||
|
||||
| Port | Direction | Content |
|
||||
|------|-----------|---------|
|
||||
| 5555 | Bridge → Simulator | Commands (JSON) |
|
||||
| 5556 | Simulator → Bridge | Telemetry (JSON) |
|
||||
|
||||
## GPS-Denied Sensors
|
||||
|
||||
All modes provide the same sensor data:
|
||||
|
||||
| Sensor | Data |
|
||||
|--------|------|
|
||||
| **IMU** | Orientation (roll, pitch, yaw), angular velocity |
|
||||
| **Altimeter** | Altitude above ground, vertical velocity |
|
||||
| **Velocity** | Estimated velocity (x, y, z) |
|
||||
| **Camera** | 320x240 downward JPEG (base64) |
|
||||
| **Landing Pad** | Relative position (x, y, distance) when visible |
|
||||
|
||||
## Configuration (config.py)
|
||||
|
||||
| Section | Parameters |
|
||||
|---------|------------|
|
||||
| `DRONE` | mass, size, color, start_position, thrust/torque scales |
|
||||
| `ROVER` | size, color, start_position, default_pattern, default_speed |
|
||||
| `CAMERA` | width, height, fov, jpeg_quality |
|
||||
| `PHYSICS` | gravity, timestep, telemetry_rate |
|
||||
| `CONTROLLER` | Kp_z, Kd_z, Kp_xy, Kd_xy, rate |
|
||||
| `LANDING` | success_distance, success_velocity, height_threshold |
|
||||
| `NETWORK` | host, command_port, telemetry_port |
|
||||
|
||||
## Platform Support
|
||||
|
||||
| Mode | Ubuntu | Arch | macOS | Windows | WSL2 |
|
||||
|------|--------|------|-------|---------|------|
|
||||
| Standalone | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| PyBullet+ROS | ✅ | ⚠️ | ❌ | ❌ | ✅ |
|
||||
| Gazebo+ROS | ✅ | ⚠️ | ❌ | ❌ | ✅ |
|
||||
| Topic | Type |
|
||||
|-------|------|
|
||||
| `/ap/pose/filtered` | Position |
|
||||
| `/ap/twist/filtered` | Velocity |
|
||||
| `/ap/imu/filtered` | IMU |
|
||||
| `/ap/battery` | Battery |
|
||||
|
||||
Reference in New Issue
Block a user