Scripts Update
This commit is contained in:
@@ -1,144 +1,116 @@
|
||||
# Setup Guide
|
||||
|
||||
## System Requirements
|
||||
Complete installation for Ubuntu 22.04/24.04 and WSL2.
|
||||
|
||||
- **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
|
||||
## One-Command Installation
|
||||
|
||||
## Installation Steps
|
||||
```bash
|
||||
git clone https://git.sirblob.co/SirBlob/simulation.git
|
||||
cd simulation
|
||||
bash setup.sh
|
||||
```
|
||||
|
||||
### 1. Install ROS 2 Humble
|
||||
The script installs:
|
||||
- ROS 2 (Humble or Jazzy)
|
||||
- Gazebo Harmonic
|
||||
- ArduPilot SITL
|
||||
- ardupilot_gazebo plugin
|
||||
- Python dependencies
|
||||
|
||||
Installation takes 20-40 minutes.
|
||||
|
||||
## Manual Installation
|
||||
|
||||
If you prefer to install components separately:
|
||||
|
||||
### 1. ROS 2
|
||||
|
||||
```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
|
||||
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
|
||||
|
||||
# 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
|
||||
sudo apt install ros-humble-ros-base ros-humble-ros-gz
|
||||
```
|
||||
|
||||
### 2. Install Gazebo Classic
|
||||
### 2. Gazebo Harmonic
|
||||
|
||||
```bash
|
||||
sudo apt install gazebo11 libgazebo11-dev ros-humble-gazebo-ros-pkgs
|
||||
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 libgz-cmake3-dev libgz-sim8-dev
|
||||
```
|
||||
|
||||
### 3. Install ArduPilot SITL
|
||||
### 3. ArduPilot SITL
|
||||
|
||||
```bash
|
||||
# Clone ArduPilot
|
||||
cd ~
|
||||
git clone https://github.com/ArduPilot/ardupilot.git
|
||||
cd ardupilot
|
||||
git submodule update --init --recursive
|
||||
|
||||
# Install dependencies
|
||||
git clone --recurse-submodules https://github.com/ArduPilot/ardupilot.git ~/ardupilot
|
||||
cd ~/ardupilot
|
||||
Tools/environment_install/install-prereqs-ubuntu.sh -y
|
||||
. ~/.profile
|
||||
|
||||
# Build SITL
|
||||
./waf configure --board sitl
|
||||
./waf copter
|
||||
```
|
||||
|
||||
### 4. Install ardupilot_gazebo Plugin
|
||||
### 4. ardupilot_gazebo Plugin
|
||||
|
||||
```bash
|
||||
cd ~
|
||||
git clone https://github.com/ArduPilot/ardupilot_gazebo.git
|
||||
cd ardupilot_gazebo
|
||||
git clone https://github.com/ArduPilot/ardupilot_gazebo.git ~/ardupilot_gazebo
|
||||
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
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release
|
||||
make -j$(nproc)
|
||||
```
|
||||
|
||||
### 5. Setup This Project
|
||||
### 5. Python Environment
|
||||
|
||||
```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
|
||||
cd ~/simulation
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## Verification
|
||||
## Verify Installation
|
||||
|
||||
### Test ROS 2
|
||||
```bash
|
||||
ros2 topic list
|
||||
```
|
||||
# Check Gazebo
|
||||
gz sim --version
|
||||
|
||||
### Test Gazebo
|
||||
```bash
|
||||
gazebo --verbose
|
||||
```
|
||||
# Check ArduPilot
|
||||
sim_vehicle.py --help
|
||||
|
||||
### 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')"
|
||||
# Check plugin
|
||||
ls ~/ardupilot_gazebo/build/libArduPilotPlugin.so
|
||||
```
|
||||
|
||||
## Running the Simulation
|
||||
|
||||
```bash
|
||||
cd ~/ros2_ws/src/uav_ugv_simulation
|
||||
cd ~/simulation
|
||||
source activate_venv.sh
|
||||
bash scripts/run_simulation.sh
|
||||
```
|
||||
|
||||
## NVIDIA GPU Setup (Optional)
|
||||
|
||||
For better Gazebo performance with NVIDIA GPU:
|
||||
## Uninstall
|
||||
|
||||
```bash
|
||||
bash scripts/setup_gazebo_nvidia.sh
|
||||
bash scripts/uninstall.sh # ArduPilot and plugin only
|
||||
bash scripts/uninstall.sh --all # Everything including project
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Package not found" error
|
||||
To remove ROS 2 and Gazebo:
|
||||
```bash
|
||||
cd ~/ros2_ws
|
||||
colcon build --packages-select uav_ugv_simulation
|
||||
source install/setup.bash
|
||||
sudo apt remove ros-humble-* gz-harmonic
|
||||
```
|
||||
|
||||
### 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`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user