145 lines
3.0 KiB
Markdown
145 lines
3.0 KiB
Markdown
# Setup Guide
|
|
|
|
## System Requirements
|
|
|
|
- **OS**: Ubuntu 22.04 LTS (Jammy Jellyfish)
|
|
- **Python**: 3.10.x (native to Ubuntu 22.04)
|
|
- **ROS 2**: Humble Hawksbill
|
|
- **Gazebo**: Classic 11
|
|
- **RAM**: 8GB minimum, 16GB recommended
|
|
- **GPU**: NVIDIA GPU recommended for better performance
|
|
|
|
## Installation Steps
|
|
|
|
### 1. Install ROS 2 Humble
|
|
|
|
```bash
|
|
# Add ROS 2 repository
|
|
sudo apt update && sudo apt install curl gnupg lsb-release
|
|
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 $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
|
|
|
|
# Install ROS 2 Humble
|
|
sudo apt update
|
|
sudo apt install ros-humble-desktop
|
|
|
|
# Source ROS 2
|
|
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
|
|
source ~/.bashrc
|
|
```
|
|
|
|
### 2. Install Gazebo Classic
|
|
|
|
```bash
|
|
sudo apt install gazebo11 libgazebo11-dev ros-humble-gazebo-ros-pkgs
|
|
```
|
|
|
|
### 3. Install ArduPilot SITL
|
|
|
|
```bash
|
|
# Clone ArduPilot
|
|
cd ~
|
|
git clone https://github.com/ArduPilot/ardupilot.git
|
|
cd ardupilot
|
|
git submodule update --init --recursive
|
|
|
|
# Install dependencies
|
|
Tools/environment_install/install-prereqs-ubuntu.sh -y
|
|
. ~/.profile
|
|
|
|
# Build SITL
|
|
./waf configure --board sitl
|
|
./waf copter
|
|
```
|
|
|
|
### 4. Install ardupilot_gazebo Plugin
|
|
|
|
```bash
|
|
cd ~
|
|
git clone https://github.com/ArduPilot/ardupilot_gazebo.git
|
|
cd ardupilot_gazebo
|
|
mkdir build && cd build
|
|
cmake ..
|
|
make -j4
|
|
sudo make install
|
|
|
|
# Add to environment
|
|
echo 'export GAZEBO_MODEL_PATH=$HOME/ardupilot_gazebo/models:$GAZEBO_MODEL_PATH' >> ~/.bashrc
|
|
echo 'export GAZEBO_RESOURCE_PATH=$HOME/ardupilot_gazebo/worlds:$GAZEBO_RESOURCE_PATH' >> ~/.bashrc
|
|
source ~/.bashrc
|
|
```
|
|
|
|
### 5. Setup This Project
|
|
|
|
```bash
|
|
# Clone to ROS 2 workspace
|
|
cd ~/ros2_ws/src
|
|
git clone <your-repo-url> uav_ugv_simulation
|
|
cd uav_ugv_simulation
|
|
|
|
# Run automated setup
|
|
bash setup.sh
|
|
|
|
# Reload environment
|
|
source ~/.bashrc
|
|
```
|
|
|
|
## Verification
|
|
|
|
### Test ROS 2
|
|
```bash
|
|
ros2 topic list
|
|
```
|
|
|
|
### Test Gazebo
|
|
```bash
|
|
gazebo --verbose
|
|
```
|
|
|
|
### Test ArduPilot SITL
|
|
```bash
|
|
cd ~/ardupilot/ArduCopter
|
|
sim_vehicle.py -v ArduCopter -f gazebo-iris --console --map
|
|
```
|
|
|
|
### Test Python Environment
|
|
```bash
|
|
cd ~/ros2_ws/src/uav_ugv_simulation
|
|
source activate_venv.sh
|
|
python -c "import cv2; import numpy; import rclpy; print('OK')"
|
|
```
|
|
|
|
## Running the Simulation
|
|
|
|
```bash
|
|
cd ~/ros2_ws/src/uav_ugv_simulation
|
|
source activate_venv.sh
|
|
bash scripts/run_simulation.sh
|
|
```
|
|
|
|
## NVIDIA GPU Setup (Optional)
|
|
|
|
For better Gazebo performance with NVIDIA GPU:
|
|
|
|
```bash
|
|
bash scripts/setup_gazebo_nvidia.sh
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### "Package not found" error
|
|
```bash
|
|
cd ~/ros2_ws
|
|
colcon build --packages-select uav_ugv_simulation
|
|
source install/setup.bash
|
|
```
|
|
|
|
### Gazebo crashes
|
|
- Check GPU drivers: `nvidia-smi`
|
|
- Try software rendering: `export LIBGL_ALWAYS_SOFTWARE=1`
|
|
|
|
### MAVROS connection failed
|
|
- Ensure ArduPilot SITL is running first
|
|
- Check port availability: `lsof -i :14550`
|
|
|