Ardupilot Install Script Fix 2
This commit is contained in:
60
README.md
60
README.md
@@ -1,17 +1,17 @@
|
|||||||
# Drone Landing Simulation (GPS-Denied)
|
# Drone Landing Simulation (GPS-Denied)
|
||||||
|
|
||||||
A GPS-denied drone landing simulation with multiple backends. Land a drone on a moving platform using only relative sensors (IMU, altimeter, camera).
|
Land a drone on a moving platform using only relative sensors (IMU, altimeter, camera).
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
### Standalone Mode (No ROS 2 - Any Platform)
|
### Standalone (1 Terminal - Any Platform)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
source activate.sh
|
source activate.sh
|
||||||
python standalone_simulation.py --pattern circular --speed 0.3
|
python standalone_simulation.py --pattern circular
|
||||||
```
|
```
|
||||||
|
|
||||||
### Gazebo + ROS 2 (Linux/WSL2)
|
### Gazebo + ROS 2 (2 Terminals)
|
||||||
|
|
||||||
**Terminal 1:**
|
**Terminal 1:**
|
||||||
```bash
|
```bash
|
||||||
@@ -22,86 +22,64 @@ ros2 launch gazebo/launch/drone_landing.launch.py
|
|||||||
```bash
|
```bash
|
||||||
source activate.sh
|
source activate.sh
|
||||||
python run_gazebo.py --pattern circular
|
python run_gazebo.py --pattern circular
|
||||||
python camera_viewer.py # Optional: view camera feed
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### ArduPilot SITL (Realistic Flight Controller)
|
### ArduPilot SITL (2 Terminals)
|
||||||
|
|
||||||
**Terminal 1:**
|
**Terminal 1:**
|
||||||
```bash
|
```bash
|
||||||
source ~/ardu_ws/install/setup.bash
|
gz sim -v4 -r ~/ardupilot_gazebo/worlds/iris_runway.sdf
|
||||||
ros2 launch ardupilot_gz_bringup iris_runway.launch.py
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Terminal 2:**
|
**Terminal 2:**
|
||||||
```bash
|
```bash
|
||||||
mavproxy.py --console --map --master=:14550
|
sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Ubuntu/Debian (includes ROS 2 + Gazebo)
|
# Ubuntu/Debian
|
||||||
./setup/install_ubuntu.sh
|
./setup/install_ubuntu.sh
|
||||||
|
|
||||||
# With ArduPilot SITL
|
# ArduPilot SITL (optional)
|
||||||
./setup/install_ardupilot.sh
|
./setup/install_ardupilot.sh
|
||||||
|
|
||||||
# Activate environment
|
# Activate environment
|
||||||
source activate.sh
|
source activate.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
| Platform | Install Script |
|
|
||||||
|----------|---------------|
|
|
||||||
| Ubuntu/Debian | `./setup/install_ubuntu.sh` |
|
|
||||||
| ArduPilot SITL | `./setup/install_ardupilot.sh` |
|
|
||||||
| Arch Linux | `./setup/install_arch.sh` |
|
|
||||||
| macOS | `./setup/install_macos.sh` |
|
|
||||||
| Windows | `.\setup\install_windows.ps1` |
|
|
||||||
|
|
||||||
## Files
|
## Files
|
||||||
|
|
||||||
| File | Description |
|
| File | Description |
|
||||||
|------|-------------|
|
|------|-------------|
|
||||||
| `standalone_simulation.py` | **All-in-one** (no ROS 2) |
|
| `standalone_simulation.py` | All-in-one simulation |
|
||||||
| `run_gazebo.py` | Gazebo controllers |
|
| `run_gazebo.py` | Gazebo controllers |
|
||||||
| `run_ardupilot.py` | ArduPilot launcher |
|
|
||||||
| `camera_viewer.py` | Drone camera window |
|
|
||||||
| `drone_controller.py` | **Your landing algorithm** |
|
| `drone_controller.py` | **Your landing algorithm** |
|
||||||
|
| `camera_viewer.py` | Drone camera window |
|
||||||
| `config.py` | Configuration |
|
| `config.py` | Configuration |
|
||||||
|
|
||||||
## Sensors Available
|
## Sensors
|
||||||
|
|
||||||
| Sensor | Data |
|
| Sensor | Data |
|
||||||
|--------|------|
|
|--------|------|
|
||||||
| IMU | Orientation (roll, pitch, yaw), angular velocity |
|
| IMU | Orientation, angular velocity |
|
||||||
| Altimeter | Altitude, vertical velocity |
|
| Altimeter | Altitude, vertical velocity |
|
||||||
| Velocity | Estimated velocity (x, y, z) |
|
| Camera | 320x240 downward image |
|
||||||
| Camera | Downward-facing image |
|
| Landing Pad | Relative position (when visible) |
|
||||||
| Landing Pad | Relative position when visible |
|
|
||||||
|
|
||||||
## Configuration
|
## Options
|
||||||
|
|
||||||
Edit `config.py` to customize:
|
|
||||||
- Drone/rover positions
|
|
||||||
- Controller gains (Kp, Kd)
|
|
||||||
- Camera settings
|
|
||||||
- Landing thresholds
|
|
||||||
|
|
||||||
## Command Line Options
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Movement patterns
|
|
||||||
--pattern, -p stationary, linear, circular, square, random
|
--pattern, -p stationary, linear, circular, square, random
|
||||||
--speed, -s Speed in m/s (default: 0.5)
|
--speed, -s Speed in m/s (default: 0.5)
|
||||||
--amplitude, -a Amplitude in meters (default: 2.0)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
| Document | Description |
|
| Document | Description |
|
||||||
|----------|-------------|
|
|----------|-------------|
|
||||||
| [Installation](docs/installation.md) | Full setup guide |
|
| [Installation](docs/installation.md) | Setup guide |
|
||||||
| [Architecture](docs/architecture.md) | System overview |
|
| [Architecture](docs/architecture.md) | System overview |
|
||||||
| [ArduPilot](docs/ardupilot.md) | ArduPilot SITL guide |
|
| [ArduPilot](docs/ardupilot.md) | ArduPilot SITL |
|
||||||
| [Gazebo](docs/gazebo.md) | Gazebo guide |
|
| [Drone Guide](docs/drone_guide.md) | Algorithm guide |
|
||||||
@@ -2,9 +2,7 @@
|
|||||||
|
|
||||||
## Operation Modes
|
## Operation Modes
|
||||||
|
|
||||||
### 1. Standalone (Any Platform)
|
### 1. Standalone (Any Platform, 1 Terminal)
|
||||||
|
|
||||||
Single process, no ROS 2 required:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python standalone_simulation.py --pattern circular
|
python standalone_simulation.py --pattern circular
|
||||||
@@ -13,11 +11,7 @@ python standalone_simulation.py --pattern circular
|
|||||||
```
|
```
|
||||||
┌────────────────────────────────────────┐
|
┌────────────────────────────────────────┐
|
||||||
│ standalone_simulation.py │
|
│ standalone_simulation.py │
|
||||||
│ ┌──────────────────────────────────┐ │
|
│ PyBullet Physics + Camera + Controllers│
|
||||||
│ │ PyBullet Physics + Camera │ │
|
|
||||||
│ │ Built-in Controller │ │
|
|
||||||
│ │ Rover Movement │ │
|
|
||||||
│ └──────────────────────────────────┘ │
|
|
||||||
└────────────────────────────────────────┘
|
└────────────────────────────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -41,54 +35,55 @@ Terminal 1 Terminal 2
|
|||||||
└───────────────────┘ └───────────────────┘
|
└───────────────────┘ └───────────────────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. ArduPilot SITL (2 Terminals)
|
### 3. ArduPilot SITL + Gazebo (2 Terminals)
|
||||||
|
|
||||||
**Terminal 1:**
|
**Terminal 1:**
|
||||||
```bash
|
```bash
|
||||||
ros2 launch ardupilot_gz_bringup iris_runway.launch.py
|
gz sim -v4 -r ~/ardupilot_gazebo/worlds/iris_runway.sdf
|
||||||
```
|
```
|
||||||
|
|
||||||
**Terminal 2:**
|
**Terminal 2:**
|
||||||
```bash
|
```bash
|
||||||
mavproxy.py --console --map --master=:14550
|
sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
┌─────────────────────────────────────────────┐
|
Terminal 1 Terminal 2
|
||||||
│ Single Launch Command │
|
┌───────────────────┐ ┌───────────────────┐
|
||||||
│ (Starts SITL + Gazebo + RViz) │
|
│ Gazebo + │◄──────►│ ArduPilot SITL │
|
||||||
├─────────────────────────────────────────────┤
|
│ ArduPilot Plugin │ JSON │ + MAVProxy │
|
||||||
│ ArduPilot SITL ◄──► Gazebo ◄──► ROS 2 │
|
└───────────────────┘ UDP └───────────────────┘
|
||||||
│ ▲ │
|
|
||||||
│ │ /ap/* topics │
|
|
||||||
│ ▼ │
|
|
||||||
│ MAVProxy (GCS) │
|
|
||||||
└─────────────────────────────────────────────┘
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Key features:**
|
||||||
|
- Full ArduPilot flight controller
|
||||||
|
- EKF, stabilization, failsafes
|
||||||
|
- MAVLink protocol
|
||||||
|
- Compatible with QGroundControl, Mission Planner
|
||||||
|
|
||||||
## Key Components
|
## Key Components
|
||||||
|
|
||||||
| Component | Description |
|
| Component | Description |
|
||||||
|-----------|-------------|
|
|-----------|-------------|
|
||||||
|
| `standalone_simulation.py` | All-in-one PyBullet simulation |
|
||||||
|
| `run_gazebo.py` | Gazebo bridge + controllers |
|
||||||
| `drone_controller.py` | Your landing algorithm |
|
| `drone_controller.py` | Your landing algorithm |
|
||||||
| `gazebo_bridge.py` | Gazebo ↔ ROS bridge |
|
| `camera_viewer.py` | Camera display window |
|
||||||
| `mavlink_bridge.py` | MAVLink commands |
|
|
||||||
| `camera_viewer.py` | Camera display |
|
|
||||||
|
|
||||||
## ROS 2 Topics
|
## ROS 2 Topics (Gazebo Mode)
|
||||||
|
|
||||||
| Topic | Direction | Description |
|
| Topic | Direction | Description |
|
||||||
|-------|-----------|-------------|
|
|-------|-----------|-------------|
|
||||||
| `/drone/telemetry` | ← | Sensor data (JSON) |
|
| `/drone/telemetry` | ← | Sensor data (JSON) |
|
||||||
| `/cmd_vel` | → | Velocity commands |
|
| `/cmd_vel` | → | Velocity commands |
|
||||||
| `/drone/camera` | ← | Camera images |
|
| `/drone/camera` | ← | Camera images |
|
||||||
| `/rover/telemetry` | ← | Landing pad position |
|
|
||||||
|
|
||||||
## ArduPilot Topics
|
## Sensors
|
||||||
|
|
||||||
| Topic | Type |
|
| Sensor | Data |
|
||||||
|-------|------|
|
|--------|------|
|
||||||
| `/ap/pose/filtered` | Position |
|
| IMU | orientation, angular_velocity |
|
||||||
| `/ap/twist/filtered` | Velocity |
|
| Altimeter | altitude, vertical_velocity |
|
||||||
| `/ap/imu/filtered` | IMU |
|
| Velocity | x, y, z (m/s) |
|
||||||
| `/ap/battery` | Battery |
|
| Camera | 320x240 image |
|
||||||
|
| Landing Pad | relative_x, relative_y (when visible) |
|
||||||
|
|||||||
@@ -2,17 +2,16 @@
|
|||||||
|
|
||||||
Run the simulation with a realistic ArduPilot flight controller.
|
Run the simulation with a realistic ArduPilot flight controller.
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start (2 Terminals)
|
||||||
|
|
||||||
**Terminal 1 - Simulation:**
|
**Terminal 1 - Gazebo:**
|
||||||
```bash
|
```bash
|
||||||
source ~/ardu_ws/install/setup.bash
|
gz sim -v4 -r ~/ardupilot_gazebo/worlds/iris_runway.sdf
|
||||||
ros2 launch ardupilot_gz_bringup iris_runway.launch.py
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Terminal 2 - Control:**
|
**Terminal 2 - SITL + MAVProxy:**
|
||||||
```bash
|
```bash
|
||||||
mavproxy.py --console --map --master=:14550
|
sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@@ -23,79 +22,81 @@ source ~/.bashrc
|
|||||||
```
|
```
|
||||||
|
|
||||||
This installs:
|
This installs:
|
||||||
- ArduPilot SITL with DDS
|
- ArduPilot SITL
|
||||||
- Gazebo with ardupilot_gz
|
- Gazebo Harmonic
|
||||||
|
- ardupilot_gazebo plugin
|
||||||
- MAVProxy
|
- MAVProxy
|
||||||
|
|
||||||
## MAVProxy Commands
|
## MAVProxy Commands
|
||||||
|
|
||||||
|
Once `sim_vehicle.py` is running:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Set mode
|
# Set GUIDED mode
|
||||||
mode guided
|
mode guided
|
||||||
|
|
||||||
# Arm
|
# Arm
|
||||||
arm throttle
|
arm throttle
|
||||||
|
|
||||||
# Takeoff
|
# Takeoff to 5m
|
||||||
takeoff 5
|
takeoff 5
|
||||||
|
|
||||||
# Land
|
# Land
|
||||||
mode land
|
mode land
|
||||||
|
|
||||||
|
# Disarm
|
||||||
|
disarm
|
||||||
```
|
```
|
||||||
|
|
||||||
## ROS 2 Topics
|
|
||||||
|
|
||||||
ArduPilot publishes native ROS 2 topics:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# List topics
|
|
||||||
ros2 topic list
|
|
||||||
|
|
||||||
# View position
|
|
||||||
ros2 topic echo /ap/geopose/filtered
|
|
||||||
|
|
||||||
# View battery
|
|
||||||
ros2 topic echo /ap/battery
|
|
||||||
```
|
|
||||||
|
|
||||||
| Topic | Type |
|
|
||||||
|-------|------|
|
|
||||||
| `/ap/pose/filtered` | PoseStamped |
|
|
||||||
| `/ap/twist/filtered` | TwistStamped |
|
|
||||||
| `/ap/imu/filtered` | Imu |
|
|
||||||
| `/ap/battery` | BatteryState |
|
|
||||||
|
|
||||||
## Available Worlds
|
## Available Worlds
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Iris on runway
|
# Iris on runway
|
||||||
ros2 launch ardupilot_gz_bringup iris_runway.launch.py
|
gz sim -v4 -r ~/ardupilot_gazebo/worlds/iris_runway.sdf
|
||||||
|
|
||||||
# Iris in maze
|
# Zephyr plane
|
||||||
ros2 launch ardupilot_gz_bringup iris_maze.launch.py
|
gz sim -v4 -r ~/ardupilot_gazebo/worlds/zephyr_runway.sdf
|
||||||
|
|
||||||
# Rover
|
|
||||||
ros2 launch ardupilot_gz_bringup wildthumper_playpen.launch.py
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using the Launcher
|
## Standalone SITL (No Gazebo)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python run_ardupilot.py --world runway
|
sim_vehicle.py -v ArduCopter --console --map
|
||||||
python run_ardupilot.py --world maze
|
|
||||||
python run_ardupilot.py --vehicle rover
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
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
|
## Troubleshooting
|
||||||
|
|
||||||
**No ROS 2 topics:**
|
**sim_vehicle.py not found:**
|
||||||
```bash
|
```bash
|
||||||
# Check DDS is enabled
|
export PATH=$PATH:~/ardupilot/Tools/autotest
|
||||||
param set DDS_ENABLE 1
|
```
|
||||||
|
|
||||||
|
**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:**
|
**Can't arm:**
|
||||||
```bash
|
```bash
|
||||||
# Disable pre-arm checks (simulation only)
|
# In MAVProxy, disable pre-arm checks
|
||||||
param set ARMING_CHECK 0
|
param set ARMING_CHECK 0
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,22 +1,17 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# ArduPilot ROS 2 + Gazebo Installation Script
|
# ArduPilot SITL + Gazebo Installation Script (MAVLink Mode)
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Installs the official ArduPilot ROS 2 packages with DDS and Gazebo support.
|
# Installs ArduPilot SITL with the ardupilot_gazebo plugin.
|
||||||
|
# This uses MAVLink instead of DDS - simpler and more reliable.
|
||||||
#
|
#
|
||||||
# Usage: ./install_ardupilot.sh
|
# Usage: ./install_ardupilot.sh
|
||||||
#
|
|
||||||
# This installs:
|
|
||||||
# 1. Micro-XRCE-DDS-Gen (required for DDS)
|
|
||||||
# 2. ArduPilot SITL with DDS support
|
|
||||||
# 3. ardupilot_gz - ArduPilot Gazebo integration
|
|
||||||
# 4. MAVProxy ground control station
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "=============================================="
|
echo "=============================================="
|
||||||
echo " ArduPilot ROS 2 + Gazebo Installation"
|
echo " ArduPilot SITL + Gazebo Installation"
|
||||||
echo "=============================================="
|
echo "=============================================="
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
@@ -25,175 +20,111 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|||||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||||
|
|
||||||
# Directories
|
# Directories
|
||||||
ARDUPILOT_WS="$HOME/ardu_ws"
|
ARDUPILOT_HOME="$HOME/ardupilot"
|
||||||
|
ARDUPILOT_GZ="$HOME/ardupilot_gazebo"
|
||||||
|
|
||||||
# Check for ROS 2
|
# Check for ROS 2
|
||||||
if [ ! -f "/opt/ros/humble/setup.bash" ] && [ ! -f "/opt/ros/jazzy/setup.bash" ]; then
|
|
||||||
echo "[ERROR] ROS 2 not found!"
|
|
||||||
echo "Install with: ./setup/install_ubuntu.sh"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Source ROS 2
|
|
||||||
if [ -f "/opt/ros/humble/setup.bash" ]; then
|
if [ -f "/opt/ros/humble/setup.bash" ]; then
|
||||||
source /opt/ros/humble/setup.bash
|
source /opt/ros/humble/setup.bash
|
||||||
ROS_DISTRO="humble"
|
ROS_DISTRO="humble"
|
||||||
elif [ -f "/opt/ros/jazzy/setup.bash" ]; then
|
elif [ -f "/opt/ros/jazzy/setup.bash" ]; then
|
||||||
source /opt/ros/jazzy/setup.bash
|
source /opt/ros/jazzy/setup.bash
|
||||||
ROS_DISTRO="jazzy"
|
ROS_DISTRO="jazzy"
|
||||||
|
else
|
||||||
|
echo "[WARN] ROS 2 not found, will install in standalone mode"
|
||||||
|
ROS_DISTRO=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
GZ_VERSION="harmonic"
|
echo "[INFO] ROS 2: ${ROS_DISTRO:-not installed}"
|
||||||
|
|
||||||
echo "[INFO] ROS 2: $ROS_DISTRO"
|
|
||||||
echo "[INFO] Gazebo: $GZ_VERSION"
|
|
||||||
echo "[INFO] Workspace: $ARDUPILOT_WS"
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Step 1: System Dependencies
|
# Step 1: System Dependencies
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
echo "[STEP 1/7] Installing system dependencies..."
|
echo "[STEP 1/5] Installing system dependencies..."
|
||||||
|
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y \
|
sudo apt-get install -y \
|
||||||
git cmake build-essential \
|
git cmake build-essential \
|
||||||
python3 python3-pip python3-dev python3-venv \
|
python3 python3-pip python3-dev \
|
||||||
python3-vcstool python3-rosdep python3-colcon-common-extensions \
|
wget curl
|
||||||
wget curl default-jre gradle
|
|
||||||
|
|
||||||
echo "[OK] System dependencies"
|
echo "[OK] System dependencies"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Step 2: Install Micro-XRCE-DDS-Gen (required for DDS)
|
# Step 2: Clone and Setup ArduPilot
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 2/7] Installing Micro-XRCE-DDS-Gen..."
|
echo "[STEP 2/5] Setting up ArduPilot SITL..."
|
||||||
|
|
||||||
XRCEDDSGEN_DIR="$HOME/Micro-XRCE-DDS-Gen"
|
if [ ! -d "$ARDUPILOT_HOME" ]; then
|
||||||
|
git clone --recurse-submodules https://github.com/ArduPilot/ardupilot.git "$ARDUPILOT_HOME"
|
||||||
if ! command -v microxrceddsgen &> /dev/null; then
|
|
||||||
if [ ! -d "$XRCEDDSGEN_DIR" ]; then
|
|
||||||
git clone --recurse-submodules https://github.com/eProsima/Micro-XRCE-DDS-Gen.git "$XRCEDDSGEN_DIR"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$XRCEDDSGEN_DIR"
|
cd "$ARDUPILOT_HOME"
|
||||||
./gradlew assemble
|
|
||||||
|
|
||||||
# Add to PATH
|
# Install ArduPilot prerequisites
|
||||||
if ! grep -q "Micro-XRCE-DDS-Gen" ~/.bashrc; then
|
Tools/environment_install/install-prereqs-ubuntu.sh -y
|
||||||
echo "" >> ~/.bashrc
|
. ~/.profile || true
|
||||||
echo "# Micro-XRCE-DDS-Gen" >> ~/.bashrc
|
|
||||||
echo "export PATH=\$PATH:$XRCEDDSGEN_DIR/scripts" >> ~/.bashrc
|
|
||||||
fi
|
|
||||||
export PATH=$PATH:$XRCEDDSGEN_DIR/scripts
|
|
||||||
|
|
||||||
echo "[OK] Micro-XRCE-DDS-Gen installed"
|
# Build ArduCopter SITL (without DDS to avoid complexity)
|
||||||
else
|
./waf configure --board sitl
|
||||||
echo "[OK] Micro-XRCE-DDS-Gen already installed"
|
./waf copter
|
||||||
fi
|
|
||||||
|
echo "[OK] ArduPilot SITL built"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Step 3: Install Gazebo Harmonic
|
# Step 3: Install Gazebo Harmonic
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 3/7] Installing Gazebo Harmonic..."
|
echo "[STEP 3/5] Installing Gazebo..."
|
||||||
|
|
||||||
|
# Add Gazebo repo
|
||||||
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg 2>/dev/null
|
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg 2>/dev/null
|
||||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y gz-harmonic || echo "[WARN] Could not install gz-harmonic"
|
|
||||||
|
|
||||||
echo "[OK] Gazebo"
|
# Install Gazebo
|
||||||
|
sudo apt-get install -y gz-harmonic || sudo apt-get install -y gz-garden || {
|
||||||
# -----------------------------------------------------------------------------
|
echo "[WARN] Could not install Gazebo Harmonic/Garden"
|
||||||
# Step 4: Create ArduPilot Workspace
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
echo ""
|
|
||||||
echo "[STEP 4/7] Setting up ArduPilot workspace..."
|
|
||||||
|
|
||||||
mkdir -p "$ARDUPILOT_WS/src"
|
|
||||||
cd "$ARDUPILOT_WS"
|
|
||||||
|
|
||||||
# Import ArduPilot repos
|
|
||||||
vcs import --recursive src < <(cat << 'EOF'
|
|
||||||
repositories:
|
|
||||||
ardupilot:
|
|
||||||
type: git
|
|
||||||
url: https://github.com/ArduPilot/ardupilot.git
|
|
||||||
version: master
|
|
||||||
ardupilot_gz:
|
|
||||||
type: git
|
|
||||||
url: https://github.com/ArduPilot/ardupilot_gz.git
|
|
||||||
version: main
|
|
||||||
EOF
|
|
||||||
) || true
|
|
||||||
|
|
||||||
# Import Gazebo packages
|
|
||||||
vcs import --input https://raw.githubusercontent.com/ArduPilot/ardupilot_gz/main/ros2_gz.repos --recursive src 2>/dev/null || true
|
|
||||||
|
|
||||||
echo "[OK] Repositories imported"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Step 5: Install ArduPilot Prerequisites
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
echo ""
|
|
||||||
echo "[STEP 5/7] Installing ArduPilot prerequisites..."
|
|
||||||
|
|
||||||
cd "$ARDUPILOT_WS/src/ardupilot"
|
|
||||||
Tools/environment_install/install-prereqs-ubuntu.sh -y
|
|
||||||
. ~/.profile || true
|
|
||||||
|
|
||||||
echo "[OK] ArduPilot prerequisites"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# Step 6: Configure rosdep and Build
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
echo ""
|
|
||||||
echo "[STEP 6/7] Building packages..."
|
|
||||||
|
|
||||||
# Configure rosdep
|
|
||||||
if [ ! -f /etc/ros/rosdep/sources.list.d/20-default.list ]; then
|
|
||||||
sudo rosdep init || true
|
|
||||||
fi
|
|
||||||
rosdep update
|
|
||||||
|
|
||||||
# Add Gazebo Harmonic sources
|
|
||||||
sudo wget https://raw.githubusercontent.com/osrf/osrf-rosdep/master/gz/00-gazebo.list \
|
|
||||||
-O /etc/ros/rosdep/sources.list.d/00-gazebo.list 2>/dev/null || true
|
|
||||||
rosdep update || true
|
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
cd "$ARDUPILOT_WS"
|
|
||||||
rosdep install --from-paths src --ignore-src -y || true
|
|
||||||
|
|
||||||
# Build
|
|
||||||
source /opt/ros/$ROS_DISTRO/setup.bash
|
|
||||||
export GZ_VERSION=$GZ_VERSION
|
|
||||||
colcon build --packages-up-to ardupilot_gz_bringup --symlink-install --allow-overriding ros_gz_bridge ros_gz_sim sdformat_urdf || {
|
|
||||||
echo "[WARN] Full build failed, trying ardupilot_sitl only..."
|
|
||||||
colcon build --packages-up-to ardupilot_sitl --symlink-install
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "[OK] Build complete"
|
echo "[OK] Gazebo installed"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Step 7: Configure Environment
|
# Step 4: Build ArduPilot Gazebo Plugin
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 7/7] Configuring environment..."
|
echo "[STEP 4/5] Building ArduPilot Gazebo plugin..."
|
||||||
|
|
||||||
BASHRC_MARKER="# === ArduPilot ROS 2 ==="
|
if [ ! -d "$ARDUPILOT_GZ" ]; then
|
||||||
|
git clone https://github.com/ArduPilot/ardupilot_gazebo.git "$ARDUPILOT_GZ"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$ARDUPILOT_GZ"
|
||||||
|
mkdir -p build && cd build
|
||||||
|
cmake .. -DCMAKE_BUILD_TYPE=Release
|
||||||
|
make -j$(nproc)
|
||||||
|
|
||||||
|
echo "[OK] ArduPilot Gazebo plugin built"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Step 5: Configure Environment
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "[STEP 5/5] Configuring environment..."
|
||||||
|
|
||||||
|
BASHRC_MARKER="# === ArduPilot SITL ==="
|
||||||
|
|
||||||
if ! grep -q "$BASHRC_MARKER" ~/.bashrc; then
|
if ! grep -q "$BASHRC_MARKER" ~/.bashrc; then
|
||||||
cat >> ~/.bashrc << EOF
|
cat >> ~/.bashrc << EOF
|
||||||
|
|
||||||
$BASHRC_MARKER
|
$BASHRC_MARKER
|
||||||
export GZ_VERSION=$GZ_VERSION
|
export ARDUPILOT_HOME=$ARDUPILOT_HOME
|
||||||
export PATH=\$PATH:$ARDUPILOT_WS/src/ardupilot/Tools/autotest
|
export PATH=\$PATH:$ARDUPILOT_HOME/Tools/autotest
|
||||||
export PATH=\$PATH:\$HOME/.local/bin
|
export PATH=\$PATH:\$HOME/.local/bin
|
||||||
source /opt/ros/$ROS_DISTRO/setup.bash
|
export GZ_SIM_SYSTEM_PLUGIN_PATH=$ARDUPILOT_GZ/build:\$GZ_SIM_SYSTEM_PLUGIN_PATH
|
||||||
[ -f $ARDUPILOT_WS/install/setup.bash ] && source $ARDUPILOT_WS/install/setup.bash
|
export GZ_SIM_RESOURCE_PATH=$ARDUPILOT_GZ/models:$ARDUPILOT_GZ/worlds:\$GZ_SIM_RESOURCE_PATH
|
||||||
EOF
|
EOF
|
||||||
echo "[OK] Environment configured"
|
echo "[OK] Environment configured"
|
||||||
else
|
else
|
||||||
@@ -201,20 +132,23 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Install MAVProxy
|
# Install MAVProxy
|
||||||
pip3 install --user pymavlink mavproxy || true
|
pip3 install --user pymavlink mavproxy
|
||||||
|
|
||||||
# Verify
|
# -----------------------------------------------------------------------------
|
||||||
|
# Verification
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "=============================================="
|
echo "=============================================="
|
||||||
echo " Verifying Installation"
|
echo " Verifying Installation"
|
||||||
echo "=============================================="
|
echo "=============================================="
|
||||||
|
|
||||||
source "$ARDUPILOT_WS/install/setup.bash" 2>/dev/null || true
|
source ~/.bashrc 2>/dev/null || true
|
||||||
|
export PATH=$PATH:$ARDUPILOT_HOME/Tools/autotest:$HOME/.local/bin
|
||||||
|
|
||||||
ros2 pkg list 2>/dev/null | grep -q "ardupilot_sitl" && echo "[OK] ardupilot_sitl" || echo "[WARN] ardupilot_sitl not found"
|
command -v sim_vehicle.py &> /dev/null && echo "[OK] sim_vehicle.py" || echo "[WARN] sim_vehicle.py not found"
|
||||||
ros2 pkg list 2>/dev/null | grep -q "ardupilot_gz_bringup" && echo "[OK] ardupilot_gz_bringup" || echo "[WARN] ardupilot_gz_bringup not found"
|
command -v gz &> /dev/null && echo "[OK] Gazebo (gz)" || echo "[WARN] Gazebo not found"
|
||||||
command -v microxrceddsgen &> /dev/null && echo "[OK] microxrceddsgen" || echo "[WARN] microxrceddsgen not in PATH"
|
command -v mavproxy.py &> /dev/null && echo "[OK] MAVProxy" || echo "[WARN] MAVProxy not in PATH"
|
||||||
command -v mavproxy.py &> /dev/null && echo "[OK] MAVProxy" || echo "[WARN] MAVProxy not in PATH (add ~/.local/bin to PATH)"
|
[ -f "$ARDUPILOT_GZ/build/libArduPilotPlugin.so" ] && echo "[OK] ArduPilot Gazebo plugin" || echo "[WARN] Plugin not built"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "=============================================="
|
echo "=============================================="
|
||||||
@@ -225,10 +159,12 @@ echo "Run: source ~/.bashrc"
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Quick Start (2 terminals):"
|
echo "Quick Start (2 terminals):"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Terminal 1:"
|
echo "Terminal 1 - Start Gazebo:"
|
||||||
echo " source ~/ardu_ws/install/setup.bash"
|
echo " gz sim -v4 -r $ARDUPILOT_GZ/worlds/iris_runway.sdf"
|
||||||
echo " ros2 launch ardupilot_gz_bringup iris_runway.launch.py"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Terminal 2:"
|
echo "Terminal 2 - Start SITL + MAVProxy:"
|
||||||
echo " mavproxy.py --console --map --master=:14550"
|
echo " sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console"
|
||||||
|
echo ""
|
||||||
|
echo "Or use sim_vehicle.py standalone (no Gazebo):"
|
||||||
|
echo " sim_vehicle.py -v ArduCopter --console --map"
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user