Files
simulation/docs/setup_guide.md
2026-02-09 05:51:51 +00:00

133 lines
3.1 KiB
Markdown

# Setup Guide
## Prerequisites
- Ubuntu 22.04 (Humble) or 24.04 (Jazzy)
- 16GB RAM minimum
- 50GB free disk space
- Internet connection
## Automatic Installation
The `setup.sh` script installs everything automatically:
```bash
cd ~/sim/uav_ugv_simulation
bash setup.sh
```
### What Gets Installed
1. **ROS 2** (Humble or Jazzy based on Ubuntu version)
2. **Gazebo Harmonic** (modern simulation)
3. **ArduPilot SITL** (flight controller)
4. **ardupilot_gazebo plugin** (ArduPilot-Gazebo bridge)
5. **Python dependencies** (pymavlink, opencv, scipy, etc.)
6. **MAVROS** (ROS 2 - MAVLink bridge)
### Installation Time
- First install: 20-40 minutes
- ArduPilot build: ~15 minutes
- Gazebo plugin build: ~5 minutes
## Manual Installation
### Step 1: Install ROS 2
```bash
# Ubuntu 22.04
sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update
sudo apt install ros-humble-desktop
```
### Step 2: Install Gazebo Harmonic
```bash
sudo apt install -y wget
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
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
sudo apt update
sudo apt install gz-harmonic
```
### Step 3: Install ArduPilot
```bash
cd ~
git clone --recurse-submodules https://github.com/ArduPilot/ardupilot.git
cd ardupilot
Tools/environment_install/install-prereqs-ubuntu.sh -y
. ~/.profile
./waf configure --board sitl
./waf copter
```
### Step 4: Install ardupilot_gazebo Plugin
```bash
cd ~
git clone https://github.com/ArduPilot/ardupilot_gazebo.git
cd ardupilot_gazebo
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j4
```
### Step 5: Install Python Dependencies
```bash
cd ~/sim/uav_ugv_simulation
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```
## Environment Setup
After installation, source the environment:
```bash
source ~/sim/uav_ugv_simulation/activate_venv.sh
```
This sets up:
- Python virtual environment
- Gazebo resource paths
- ArduPilot paths
## Verify Installation
```bash
# Check Gazebo
gz sim --version
# Check ArduPilot
sim_vehicle.py --help
# Check Python deps
python3 -c "import pymavlink; print('pymavlink OK')"
python3 -c "import cv2; print('opencv OK')"
```
## Uninstall
```bash
# Remove ArduPilot and plugin only
bash scripts/uninstall.sh
# Remove everything including venv
bash scripts/uninstall.sh --all
```
## Next Steps
1. Run a test simulation: `bash scripts/run_autonomous.sh --mission hover`
2. Read the [Usage Guide](usage.md)
3. Check [Troubleshooting](troubleshooting.md) if issues arise