feat: Simplify drone controller to basic flight pattern, overhaul installation guide, and update related scripts.

This commit is contained in:
2026-01-07 21:02:31 +00:00
parent 760293d896
commit e266f75fca
9 changed files with 919 additions and 1407 deletions

View File

@@ -1,230 +1,174 @@
# Installation
# Installation Guide
## Quick Install (Ubuntu/WSL)
## System Requirements
- **OS**: Ubuntu 22.04 or 24.04 (Windows users: use WSL2)
- **RAM**: 8GB minimum, 16GB recommended
- **Disk**: 10GB free space
- **GPU**: Any GPU with OpenGL 3.3+ support
## Quick Install (Ubuntu)
```bash
./setup/install_ubuntu.sh
./setup/install_ardupilot.sh
# Clone repository
git clone <repo-url> RDC_Simulation
cd RDC_Simulation
# Run installer (includes ArduPilot)
./setup/install_ubuntu.sh --with-ardupilot
# Reload shell
source ~/.bashrc
```
## What Gets Installed
This installs:
- Python 3 + virtual environment
- Gazebo Harmonic
- ArduPilot SITL
- ArduPilot Gazebo plugin
- MAVProxy
| Component | Location |
|-----------|----------|
| ArduPilot SITL | `~/ardupilot` |
| ArduPilot venv | `~/venv-ardupilot` |
| ardupilot_gazebo | `~/ardupilot_gazebo` |
| Gazebo Harmonic | System |
| ROS 2 | System |
| MAVProxy | `~/.local/bin` |
## Windows (WSL2)
## Platform-Specific Installation
### Ubuntu (Native)
```bash
./setup/install_ubuntu.sh --with-ardupilot
```
### Windows (via WSL2)
WSL2 (Windows Subsystem for Linux) is the recommended way to run this simulation on Windows.
#### Step 1: Install WSL2
### Step 1: Install WSL2
Open PowerShell as Administrator:
```powershell
wsl --install -d Ubuntu-24.04
```
Restart computer, then open Ubuntu from Start menu.
Restart your computer when prompted.
### Step 2: Install in WSL
#### Step 2: Configure WSL2 for GUI Apps
WSL2 on Windows 11 has built-in GUI support (WSLg). For Windows 10, you may need an X server:
```powershell
# Windows 11 - WSLg is automatic, no extra setup needed
# Windows 10 - Install VcXsrv or X410 from Microsoft Store
```
#### Step 3: Install in WSL
Open Ubuntu from Start menu:
```bash
# Clone the project (or copy from Windows)
git clone https://github.com/your-repo/RDC_Simulation.git
cd RDC_Simulation
# Update system
sudo apt update && sudo apt upgrade -y
# Run installation
./setup/install_ubuntu.sh
./setup/install_ardupilot.sh
# Clone and install
git clone <repo-url> ~/RDC_Simulation
cd ~/RDC_Simulation
./setup/install_ubuntu.sh --with-ardupilot
# Reload
source ~/.bashrc
```
#### Step 4: GPU Acceleration in WSL
### WSL2 Tips
For best performance with Gazebo:
```bash
# Check GPU availability
glxinfo | grep "OpenGL renderer"
# Should show your GPU, not "llvmpipe"
# If using NVIDIA, install NVIDIA GPU driver for WSL:
# https://developer.nvidia.com/cuda/wsl
```
#### WSL Tips
- **Access Windows files:** `/mnt/c/Users/YourName/`
- **Open file explorer:** `explorer.exe .`
- **Copy to clipboard:** `cat file | clip.exe`
- **Memory limit:** Create `%UserProfile%\.wslconfig`:
```ini
[wsl2]
memory=8GB
processors=4
```
### macOS
Gazebo is not officially supported on macOS. Use standalone mode:
- **GUI Apps**: Windows 11 has WSLg built-in. Gazebo should work automatically.
- **GPU**: Install NVIDIA WSL driver from [nvidia.com/wsl](https://developer.nvidia.com/cuda/wsl)
- **Access Windows files**: `/mnt/c/Users/YourName/`
- **Performance**: Clone repo to Linux filesystem (not `/mnt/c/`)
## macOS
macOS doesn't support Gazebo Harmonic natively. Options:
1. **Docker** (recommended): Use Linux container
2. **VM**: Use UTM or Parallels with Ubuntu
3. **Standalone**: Run PyBullet-only simulation
```bash
# Install basic dependencies
./setup/install_macos.sh
# Use standalone simulation
python standalone_simulation.py
```
For full simulation, use a Linux VM (UTM for Apple Silicon) or Docker.
### Arch Linux
## Arch Linux
```bash
./setup/install_arch.sh
./setup/install_arch.sh --with-ardupilot
source ~/.bashrc
```
ROS 2 and Gazebo are available via AUR - see script output for details.
## Dependencies
```bash
pip install -r requirements.txt
```
- pybullet
- numpy
- pillow
- opencv-python
- pymavlink
- pexpect
## Verify Installation
```bash
# Source the environment
source activate.sh
# Check ArduPilot tools
# Check ArduPilot
source ~/venv-ardupilot/bin/activate
python -c "import em; print('empy OK')"
sim_vehicle.py --help
which mavproxy.py
# Check Gazebo
gz sim --help
gz sim --version
ls ~/ardupilot_gazebo/build/libArduPilotPlugin.so
```
## Environment Setup
## Post-Installation
After installation, always source the environment before running:
### Environment Setup
The installer creates `activate.sh` in the project root:
```bash
cd ~/RDC_Simulation
source activate.sh
# or
source ~/.bashrc # if ArduPilot was installed
```
The activation script sets up:
- ROS 2 environment
- ArduPilot Python venv (with empy, pymavlink, etc.)
- Gazebo resource paths
- ArduPilot tools path
This sources:
- ROS 2 (if installed)
- ArduPilot virtual environment
- Gazebo paths
### First Run
```bash
# Terminal 1: Start Gazebo
./scripts/run_ardupilot_sim.sh runway
# Terminal 2: Start SITL (after Gazebo loads)
source ~/venv-ardupilot/bin/activate
sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console
# Terminal 3: Run controller
source ~/venv-ardupilot/bin/activate
cd ~/RDC_Simulation
python scripts/run_ardupilot.py --pattern square
```
## Troubleshooting
### "empy not found" or waf configure fails
### "empy not found"
The ArduPilot venv isn't activated. Run:
```bash
source ~/venv-ardupilot/bin/activate
pip install empy==3.3.4
```
### sim_vehicle.py not found
### "No JSON sensor message"
SITL isn't receiving data from Gazebo.
- Start Gazebo FIRST
- Wait for it to fully load
- Then start SITL
### "sim_vehicle.py not found"
```bash
source ~/.ardupilot_env
# or
# OR
export PATH=$PATH:~/ardupilot/Tools/autotest
```
### mavproxy.py not found
```bash
export PATH=$PATH:~/.local/bin
```
### pexpect error
```bash
pip install pexpect
```
### Gazebo slow / Software rendering
### Gazebo crashes / slow
```bash
# Check GPU
glxinfo | grep "OpenGL renderer"
```
Should show your GPU, not "llvmpipe". Install proper GPU drivers:
- **NVIDIA:** `sudo apt install nvidia-driver-XXX`
- **AMD:** `sudo apt install mesa-vulkan-drivers`
- **Intel:** Usually works out of box
- **WSL:** Install NVIDIA WSL driver from nvidia.com
### Wrong Python environment
If you see errors about missing packages that should be installed:
```bash
# Check which Python is being used
which python3
# Should be: ~/venv-ardupilot/bin/python3
# If not, activate the correct venv:
source ~/venv-ardupilot/bin/activate
# Try software rendering (slow but works)
export LIBGL_ALWAYS_SOFTWARE=1
gz sim -v4 -r ~/ardupilot_gazebo/worlds/iris_runway.sdf
```
### WSL: Display not working
```bash
# Check DISPLAY variable
echo $DISPLAY
# Check WSLg
ls /mnt/wslg
# For WSLg (Windows 11), should be auto-set
# For Windows 10 with X server:
export DISPLAY=:0
# If missing, update WSL
wsl --update
```
### WSL: Out of memory
Create `%UserProfile%\.wslconfig`:
```ini
[wsl2]
memory=8GB
swap=4GB
```
Then restart WSL: `wsl --shutdown`