WSL Support
This commit is contained in:
96
README.md
96
README.md
@@ -4,55 +4,36 @@ A GPS-denied drone landing simulation using relative sensors (IMU, altimeter, ca
|
|||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
### Windows (Standalone - No ROS 2 Required)
|
```bash
|
||||||
|
# Install (choose your platform)
|
||||||
|
./setup/install_ubuntu.sh # Ubuntu/Debian
|
||||||
|
./setup/install_arch.sh # Arch Linux
|
||||||
|
./setup/install_macos.sh # macOS
|
||||||
|
.\setup\install_windows.ps1 # Windows (PowerShell)
|
||||||
|
|
||||||
```powershell
|
# Activate and run
|
||||||
. .\activate.ps1
|
source activate.sh # Linux/macOS
|
||||||
python standalone_simulation.py
|
. .\activate.ps1 # Windows
|
||||||
|
|
||||||
# With moving rover
|
|
||||||
python standalone_simulation.py --pattern circular --speed 0.3
|
python standalone_simulation.py --pattern circular --speed 0.3
|
||||||
```
|
```
|
||||||
|
|
||||||
### Linux (Full ROS 2 Setup)
|
## Platform Compatibility
|
||||||
|
|
||||||
```bash
|
| Feature | Ubuntu | Arch | macOS | Windows |
|
||||||
source activate.sh
|
|---------|--------|------|-------|---------|
|
||||||
|
| Standalone | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| ROS 2 | ✅ | ⚠️ | ❌ | ❌ |
|
||||||
|
| Gazebo | ✅ | ⚠️ | ❌ | ❌ |
|
||||||
|
|
||||||
# Terminal 1: Simulator
|
**All platforms support standalone mode** - no ROS 2 required!
|
||||||
python simulation_host.py
|
|
||||||
|
|
||||||
# Terminal 2: ROS bridge
|
|
||||||
python ros_bridge.py
|
|
||||||
|
|
||||||
# Terminal 3: Controllers
|
|
||||||
python controllers.py --pattern circular --speed 0.3
|
|
||||||
```
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
```
|
|
||||||
┌─────────────────────────────────────────────────────────────────────────┐
|
|
||||||
│ STANDALONE MODE (Windows) FULL MODE (Linux + ROS 2) │
|
|
||||||
│ ───────────────────────── ────────────────────────── │
|
|
||||||
│ │
|
|
||||||
│ ┌──────────────────────┐ ┌───────────────┐ ┌───────────────┐ │
|
|
||||||
│ │standalone_simulation │ │simulation_host│◄──►│ ros_bridge │ │
|
|
||||||
│ │ (All-in-one) │ └───────────────┘ └───────┬───────┘ │
|
|
||||||
│ └──────────────────────┘ │ │
|
|
||||||
│ ┌─────────▼─────────┐ │
|
|
||||||
│ │ controllers.py │ │
|
|
||||||
│ │ (Drone + Rover) │ │
|
|
||||||
│ └───────────────────┘ │
|
|
||||||
└─────────────────────────────────────────────────────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
## Files
|
## Files
|
||||||
|
|
||||||
| File | Description |
|
| File | Description |
|
||||||
|------|-------------|
|
|------|-------------|
|
||||||
| `standalone_simulation.py` | **Windows: All-in-one simulation (no ROS 2)** |
|
| `standalone_simulation.py` | **All-in-one simulation (no ROS 2)** |
|
||||||
| `simulation_host.py` | PyBullet physics simulator |
|
| `simulation_host.py` | PyBullet simulator (ROS 2 mode) |
|
||||||
| `ros_bridge.py` | UDP ↔ ROS 2 bridge |
|
| `ros_bridge.py` | UDP ↔ ROS 2 bridge |
|
||||||
| `gazebo_bridge.py` | Gazebo ↔ ROS 2 bridge |
|
| `gazebo_bridge.py` | Gazebo ↔ ROS 2 bridge |
|
||||||
| `controllers.py` | Runs drone + rover controllers |
|
| `controllers.py` | Runs drone + rover controllers |
|
||||||
@@ -62,22 +43,16 @@ python controllers.py --pattern circular --speed 0.3
|
|||||||
## Controller Options
|
## Controller Options
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Standalone (Windows)
|
python standalone_simulation.py --help
|
||||||
python standalone_simulation.py --pattern circular --speed 0.3
|
|
||||||
|
|
||||||
# Full mode (Linux)
|
|
||||||
python controllers.py --pattern circular --speed 0.3
|
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--pattern, -p Rover pattern: stationary, linear, circular, square
|
--pattern, -p stationary, linear, circular, square
|
||||||
--speed, -s Rover speed in m/s (default: 0.5)
|
--speed, -s Speed in m/s (default: 0.5)
|
||||||
--amplitude, -a Rover amplitude in meters (default: 2.0)
|
--amplitude, -a Amplitude in meters (default: 2.0)
|
||||||
```
|
```
|
||||||
|
|
||||||
## GPS-Denied Sensors
|
## GPS-Denied Sensors
|
||||||
|
|
||||||
The drone has no GPS. Available sensors:
|
|
||||||
|
|
||||||
| Sensor | Data |
|
| Sensor | Data |
|
||||||
|--------|------|
|
|--------|------|
|
||||||
| **IMU** | Orientation, angular velocity |
|
| **IMU** | Orientation, angular velocity |
|
||||||
@@ -90,25 +65,16 @@ The drone has no GPS. Available sensors:
|
|||||||
|
|
||||||
| Document | Description |
|
| Document | Description |
|
||||||
|----------|-------------|
|
|----------|-------------|
|
||||||
| [Installation](docs/installation.md) | Setup for Ubuntu, macOS, Windows |
|
| [Installation](docs/installation.md) | All platform setup guides |
|
||||||
| [Architecture](docs/architecture.md) | System components and data flow |
|
| [Architecture](docs/architecture.md) | System components |
|
||||||
| [Protocol](docs/protocol.md) | Sensor data formats |
|
| [Protocol](docs/protocol.md) | Sensor data formats |
|
||||||
| [Drone Guide](docs/drone_guide.md) | How to implement landing logic |
|
| [Drone Guide](docs/drone_guide.md) | Landing algorithm guide |
|
||||||
| [Rover Controller](docs/rover_controller.md) | Movement patterns |
|
| [PyBullet](docs/pybullet.md) | PyBullet setup |
|
||||||
| [PyBullet](docs/pybullet.md) | PyBullet-specific setup |
|
| [Gazebo](docs/gazebo.md) | Gazebo setup (Linux) |
|
||||||
| [Gazebo](docs/gazebo.md) | Gazebo-specific setup (Linux only) |
|
|
||||||
|
|
||||||
## Platform Support
|
|
||||||
|
|
||||||
| Platform | Standalone | Full (ROS 2) | Gazebo |
|
|
||||||
|----------|------------|--------------|--------|
|
|
||||||
| Windows | ✅ | ⚠️ Complex | ❌ |
|
|
||||||
| Linux | ✅ | ✅ | ✅ |
|
|
||||||
| macOS | ✅ | ⚠️ Limited | ❌ |
|
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
1. **Windows**: Run `python standalone_simulation.py`
|
1. Run `python standalone_simulation.py`
|
||||||
2. **Linux**: Read [docs/drone_guide.md](docs/drone_guide.md)
|
2. Watch the drone land automatically
|
||||||
3. Edit `drone_controller.py` to implement your algorithm
|
3. Edit `drone_controller.py` to implement your own algorithm
|
||||||
4. Test with different rover patterns
|
4. Test: `python standalone_simulation.py --pattern circular`
|
||||||
@@ -1,275 +1,369 @@
|
|||||||
# Installation Guide
|
# Installation Guide
|
||||||
|
|
||||||
This guide covers installation on Ubuntu, macOS, and Windows.
|
Setup instructions for all supported platforms.
|
||||||
|
|
||||||
## Quick Install
|
## Quick Install
|
||||||
|
|
||||||
### Ubuntu / Debian
|
| Platform | Command |
|
||||||
|
|----------|---------|
|
||||||
|
| Ubuntu/Debian | `./setup/install_ubuntu.sh` |
|
||||||
|
| Arch Linux | `./setup/install_arch.sh` |
|
||||||
|
| macOS | `./setup/install_macos.sh` |
|
||||||
|
| Windows | `.\setup\install_windows.ps1` |
|
||||||
|
|
||||||
|
After installation:
|
||||||
```bash
|
```bash
|
||||||
cd simulation
|
source activate.sh # Linux/macOS
|
||||||
chmod +x setup/install_ubuntu.sh
|
. .\activate.ps1 # Windows PowerShell
|
||||||
./setup/install_ubuntu.sh
|
|
||||||
source activate.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
### macOS
|
python standalone_simulation.py
|
||||||
|
|
||||||
```bash
|
|
||||||
cd simulation
|
|
||||||
chmod +x setup/install_macos.sh
|
|
||||||
./setup/install_macos.sh
|
|
||||||
source activate.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
### Windows (PowerShell)
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
cd simulation
|
|
||||||
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
|
|
||||||
.\setup\install_windows.ps1
|
|
||||||
.\activate.bat
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## What Gets Installed
|
## Platform Compatibility
|
||||||
|
|
||||||
| Component | Description |
|
| Feature | Ubuntu | Arch | macOS | Windows | WSL2 |
|
||||||
|-----------|-------------|
|
|---------|--------|------|-------|---------|------|
|
||||||
| **ROS 2** | Humble (Ubuntu 22.04) or Jazzy (Ubuntu 24.04) |
|
| **Standalone Simulation** | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| **Gazebo** | Modern Ignition-based simulator |
|
| **ROS 2** | ✅ | ⚠️ AUR | ❌ | ❌ | ✅ |
|
||||||
| **Python venv** | Virtual environment with system site-packages |
|
| **Gazebo** | ✅ | ⚠️ AUR | ❌ | ❌ | ✅ |
|
||||||
| **PyBullet** | Lightweight physics engine |
|
| **Full Mode** | ✅ | ⚠️ | ❌ | ❌ | ✅ |
|
||||||
| **PyInstaller** | Executable bundler |
|
| **GUI Support** | ✅ | ✅ | ✅ | ✅ | ✅ WSLg |
|
||||||
| **ros_gz_bridge** | ROS 2 ↔ Gazebo topic bridge |
|
|
||||||
|
**Legend:**
|
||||||
|
- ✅ Fully supported
|
||||||
|
- ⚠️ Available but requires extra setup
|
||||||
|
- ❌ Not supported
|
||||||
|
|
||||||
|
**Recommendation for Windows users:** Use WSL2 for the full experience (ROS 2 + Gazebo).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ubuntu / Debian
|
||||||
|
|
||||||
|
**Tested on:** Ubuntu 22.04 (Jammy), Ubuntu 24.04 (Noble)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run installer
|
||||||
|
./setup/install_ubuntu.sh
|
||||||
|
|
||||||
|
# Activate environment
|
||||||
|
source activate.sh
|
||||||
|
|
||||||
|
# Run simulation
|
||||||
|
python standalone_simulation.py
|
||||||
|
```
|
||||||
|
|
||||||
|
**Installs:**
|
||||||
|
- ROS 2 (Humble or Jazzy based on Ubuntu version)
|
||||||
|
- Gazebo (ros-gz)
|
||||||
|
- Python packages: pybullet, numpy, pillow, pyinstaller
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Arch Linux
|
||||||
|
|
||||||
|
**Tested on:** Arch Linux (rolling release)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run installer
|
||||||
|
./setup/install_arch.sh
|
||||||
|
|
||||||
|
# Activate environment
|
||||||
|
source activate.sh
|
||||||
|
|
||||||
|
# Run simulation
|
||||||
|
python standalone_simulation.py
|
||||||
|
```
|
||||||
|
|
||||||
|
**Installs:**
|
||||||
|
- Python packages: pybullet, numpy, pillow, pyinstaller
|
||||||
|
- yay (AUR helper)
|
||||||
|
|
||||||
|
**Optional ROS 2 (from AUR):**
|
||||||
|
```bash
|
||||||
|
yay -S ros-humble-desktop
|
||||||
|
yay -S ros-humble-ros-gz
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## macOS
|
||||||
|
|
||||||
|
**Tested on:** macOS 12+ (Monterey, Ventura, Sonoma)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run installer
|
||||||
|
./setup/install_macos.sh
|
||||||
|
|
||||||
|
# Activate environment
|
||||||
|
source activate.sh
|
||||||
|
|
||||||
|
# Run simulation
|
||||||
|
python standalone_simulation.py
|
||||||
|
```
|
||||||
|
|
||||||
|
**Installs:**
|
||||||
|
- Homebrew (if not present)
|
||||||
|
- Python 3.11
|
||||||
|
- Python packages: pybullet, numpy, pillow, pyinstaller
|
||||||
|
|
||||||
|
**Note:** ROS 2 and Gazebo are not supported on macOS. Use standalone mode.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Windows
|
||||||
|
|
||||||
|
**Tested on:** Windows 10, Windows 11
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# Open PowerShell as Administrator
|
||||||
|
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
|
||||||
|
|
||||||
|
# Run installer
|
||||||
|
.\setup\install_windows.ps1
|
||||||
|
|
||||||
|
# Activate environment
|
||||||
|
. .\activate.ps1
|
||||||
|
|
||||||
|
# Run simulation
|
||||||
|
python standalone_simulation.py
|
||||||
|
```
|
||||||
|
|
||||||
|
**Installs:**
|
||||||
|
- Chocolatey (package manager)
|
||||||
|
- Python 3.11
|
||||||
|
- Python packages: pybullet, numpy, pillow, pyinstaller
|
||||||
|
|
||||||
|
**Note:** ROS 2 and Gazebo are not supported natively on Windows. Use standalone mode or WSL2 (below).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Windows with WSL2 (Full Linux Experience)
|
||||||
|
|
||||||
|
WSL2 lets you run full Linux on Windows with GUI support. This enables ROS 2 and Gazebo!
|
||||||
|
|
||||||
|
**Requirements:** Windows 10 (build 19041+) or Windows 11
|
||||||
|
|
||||||
|
### Step 1: Install WSL2
|
||||||
|
|
||||||
|
Open PowerShell as Administrator:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# Install WSL2 with Ubuntu
|
||||||
|
wsl --install -d Ubuntu-22.04
|
||||||
|
|
||||||
|
# Restart computer when prompted
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 2: Enable GUI Support (WSLg)
|
||||||
|
|
||||||
|
Windows 11 and recent Windows 10 updates include WSLg (GUI support) automatically.
|
||||||
|
|
||||||
|
Verify by opening Ubuntu and running:
|
||||||
|
```bash
|
||||||
|
# Test GUI (should open a window)
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install x11-apps -y
|
||||||
|
xclock
|
||||||
|
```
|
||||||
|
|
||||||
|
If xclock appears, GUI is working!
|
||||||
|
|
||||||
|
### Step 3: Install Simulation in WSL
|
||||||
|
|
||||||
|
Open Ubuntu from Start menu:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Clone or copy your project
|
||||||
|
cd ~
|
||||||
|
git clone <your-repo-url> simulation
|
||||||
|
# OR copy from Windows:
|
||||||
|
# cp -r /mnt/c/Users/YourName/simulation ~/simulation
|
||||||
|
|
||||||
|
cd simulation
|
||||||
|
|
||||||
|
# Run Ubuntu installer
|
||||||
|
./setup/install_ubuntu.sh
|
||||||
|
|
||||||
|
# Activate
|
||||||
|
source activate.sh
|
||||||
|
|
||||||
|
# Run with GUI
|
||||||
|
python standalone_simulation.py
|
||||||
|
```
|
||||||
|
|
||||||
|
### WSL2 Tips
|
||||||
|
|
||||||
|
**Access Windows files:**
|
||||||
|
```bash
|
||||||
|
# Windows C: drive is at /mnt/c/
|
||||||
|
cd /mnt/c/Users/YourName/Documents
|
||||||
|
```
|
||||||
|
|
||||||
|
**Run from Windows Terminal:**
|
||||||
|
```powershell
|
||||||
|
wsl -d Ubuntu-22.04 -e bash -c "cd ~/simulation && source activate.sh && python standalone_simulation.py"
|
||||||
|
```
|
||||||
|
|
||||||
|
**GPU Acceleration (NVIDIA):**
|
||||||
|
|
||||||
|
If you have an NVIDIA GPU:
|
||||||
|
```bash
|
||||||
|
# Check if GPU is available
|
||||||
|
nvidia-smi
|
||||||
|
|
||||||
|
# PyBullet will use hardware rendering automatically
|
||||||
|
```
|
||||||
|
|
||||||
|
**Troubleshooting WSL GUI:**
|
||||||
|
|
||||||
|
If GUI doesn't work:
|
||||||
|
```bash
|
||||||
|
# Update WSL
|
||||||
|
wsl --update
|
||||||
|
|
||||||
|
# Set WSL2 as default
|
||||||
|
wsl --set-default-version 2
|
||||||
|
|
||||||
|
# Reinstall Ubuntu
|
||||||
|
wsl --unregister Ubuntu-22.04
|
||||||
|
wsl --install -d Ubuntu-22.04
|
||||||
|
```
|
||||||
|
|
||||||
|
**Using VcXsrv (older Windows 10):**
|
||||||
|
|
||||||
|
If WSLg isn't available:
|
||||||
|
```powershell
|
||||||
|
# Install VcXsrv
|
||||||
|
choco install vcxsrv -y
|
||||||
|
```
|
||||||
|
|
||||||
|
Then in WSL:
|
||||||
|
```bash
|
||||||
|
# Add to ~/.bashrc
|
||||||
|
export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0
|
||||||
|
export LIBGL_ALWAYS_INDIRECT=1
|
||||||
|
|
||||||
|
# Start VcXsrv with "Disable access control" checked
|
||||||
|
# Then run simulation
|
||||||
|
python standalone_simulation.py
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Manual Installation
|
## Manual Installation
|
||||||
|
|
||||||
If the scripts don't work, follow these steps manually.
|
If the install scripts don't work, install manually:
|
||||||
|
|
||||||
### Step 1: Install ROS 2
|
### 1. Python 3.10+
|
||||||
|
|
||||||
#### Ubuntu 22.04 (Humble)
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt update && sudo apt install -y locales
|
# Ubuntu/Debian
|
||||||
sudo locale-gen en_US en_US.UTF-8
|
sudo apt install python3 python3-pip python3-venv
|
||||||
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
|
|
||||||
export LANG=en_US.UTF-8
|
|
||||||
|
|
||||||
sudo apt install -y software-properties-common curl
|
# Arch
|
||||||
sudo add-apt-repository -y universe
|
sudo pacman -S python python-pip python-virtualenv
|
||||||
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" \
|
# macOS
|
||||||
| sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
|
brew install python@3.11
|
||||||
|
|
||||||
sudo apt update
|
# Windows
|
||||||
sudo apt install -y ros-humble-desktop
|
# Download from https://python.org
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Ubuntu 24.04 (Jazzy)
|
### 2. Create Virtual Environment
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Same as above, but install ros-jazzy-desktop
|
python3 -m venv venv
|
||||||
sudo apt install -y ros-jazzy-desktop
|
source venv/bin/activate # Linux/macOS
|
||||||
|
# OR
|
||||||
|
.\venv\Scripts\Activate.ps1 # Windows
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 2: Install Gazebo
|
### 3. Install Python Packages
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Ubuntu 22.04
|
pip install -r requirements.txt
|
||||||
sudo apt install -y ros-humble-ros-gz ros-humble-ros-gz-bridge
|
|
||||||
|
|
||||||
# Ubuntu 24.04
|
|
||||||
sudo apt install -y ros-jazzy-ros-gz ros-jazzy-ros-gz-bridge
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 3: Create Python Virtual Environment
|
Or manually:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt install -y python3-venv python3-full
|
pip install pybullet numpy pillow pyinstaller
|
||||||
|
|
||||||
cd /path/to/simulation
|
|
||||||
python3 -m venv venv --system-site-packages
|
|
||||||
source venv/bin/activate
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 4: Install Python Dependencies
|
### 4. Run Simulation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install --upgrade pip
|
python standalone_simulation.py
|
||||||
pip install pybullet pyinstaller
|
|
||||||
```
|
|
||||||
|
|
||||||
### Step 5: Create Activation Script
|
|
||||||
|
|
||||||
Create `activate.sh`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
#!/bin/bash
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
|
|
||||||
# Source ROS 2 (adjust distro as needed)
|
|
||||||
source /opt/ros/humble/setup.bash
|
|
||||||
echo "[OK] ROS 2 sourced"
|
|
||||||
|
|
||||||
# Activate venv
|
|
||||||
source "$SCRIPT_DIR/venv/bin/activate"
|
|
||||||
echo "[OK] Python venv activated"
|
|
||||||
```
|
|
||||||
|
|
||||||
Make executable:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
chmod +x activate.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Verifying Installation
|
|
||||||
|
|
||||||
After installation, verify all components:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
source activate.sh
|
|
||||||
|
|
||||||
# Check ROS 2
|
|
||||||
ros2 --version
|
|
||||||
|
|
||||||
# Check PyBullet
|
|
||||||
python3 -c "import pybullet; print('PyBullet OK')"
|
|
||||||
|
|
||||||
# Check rclpy
|
|
||||||
python3 -c "import rclpy; print('rclpy OK')"
|
|
||||||
|
|
||||||
# Check geometry_msgs
|
|
||||||
python3 -c "from geometry_msgs.msg import Twist; print('geometry_msgs OK')"
|
|
||||||
|
|
||||||
# Check Gazebo
|
|
||||||
gz sim --version
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
### "externally-managed-environment" Error
|
### PyBullet fails to install
|
||||||
|
|
||||||
This happens on modern Ubuntu/Debian due to PEP 668. Solution: use the virtual environment.
|
Install build tools:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
source activate.sh # Activates venv
|
# Ubuntu/Debian
|
||||||
pip install pybullet # Now works
|
sudo apt install build-essential
|
||||||
|
|
||||||
|
# Arch
|
||||||
|
sudo pacman -S base-devel
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
xcode-select --install
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
# Install Visual Studio Build Tools
|
||||||
```
|
```
|
||||||
|
|
||||||
### ROS 2 Packages Not Found
|
### "Cannot connect to X server"
|
||||||
|
|
||||||
Ensure ROS 2 is sourced before activating venv:
|
PyBullet GUI requires a display:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
source /opt/ros/humble/setup.bash # or jazzy
|
# Use virtual display
|
||||||
source venv/bin/activate
|
sudo apt install xvfb
|
||||||
|
xvfb-run python standalone_simulation.py
|
||||||
|
|
||||||
|
# OR use X11 forwarding
|
||||||
|
ssh -X user@host
|
||||||
```
|
```
|
||||||
|
|
||||||
The `activate.sh` script handles this automatically.
|
### Pillow fails to install
|
||||||
|
|
||||||
### Gazebo Not Starting
|
|
||||||
|
|
||||||
Check if Gazebo is properly installed:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
which gz
|
# Ubuntu/Debian
|
||||||
gz sim --version
|
sudo apt install libjpeg-dev zlib1g-dev
|
||||||
|
|
||||||
|
# Arch
|
||||||
|
sudo pacman -S libjpeg-turbo zlib
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
brew install libjpeg zlib
|
||||||
```
|
```
|
||||||
|
|
||||||
If missing, install the ROS-Gazebo packages:
|
### Permission denied on Windows
|
||||||
|
|
||||||
```bash
|
Run PowerShell as Administrator:
|
||||||
sudo apt install ros-humble-ros-gz # or jazzy
|
|
||||||
```
|
|
||||||
|
|
||||||
### PyBullet GUI Not Showing
|
|
||||||
|
|
||||||
PyBullet requires a display. Options:
|
|
||||||
|
|
||||||
1. Run on machine with monitor
|
|
||||||
2. Use X11 forwarding: `ssh -X user@host`
|
|
||||||
3. Use virtual display: `xvfb-run python simulation_host.py`
|
|
||||||
|
|
||||||
### Permission Denied on Scripts
|
|
||||||
|
|
||||||
Make scripts executable:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
chmod +x setup/*.sh
|
|
||||||
chmod +x activate.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Platform-Specific Notes
|
|
||||||
|
|
||||||
### Ubuntu
|
|
||||||
|
|
||||||
- Full support for both PyBullet and Gazebo
|
|
||||||
- ROS 2 installed via apt packages
|
|
||||||
- Recommended platform
|
|
||||||
|
|
||||||
### macOS
|
|
||||||
|
|
||||||
- PyBullet works well
|
|
||||||
- Gazebo support is limited
|
|
||||||
- ROS 2 installed via Homebrew or binary
|
|
||||||
|
|
||||||
### Windows
|
|
||||||
|
|
||||||
- **PyBullet works fully** - GUI mode with camera
|
|
||||||
- **Gazebo NOT supported** - Linux only
|
|
||||||
- **ROS 2 optional** - Only needed for ros_bridge.py
|
|
||||||
- Use `python simulation_host.py` directly
|
|
||||||
|
|
||||||
**On Windows, the recommended workflow is:**
|
|
||||||
```powershell
|
```powershell
|
||||||
. .\activate.ps1
|
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
|
||||||
python simulation_host.py
|
|
||||||
```
|
|
||||||
|
|
||||||
The PyBullet simulation runs standalone with full GUI - no ROS 2 or Gazebo needed.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Updating
|
|
||||||
|
|
||||||
To update the simulation framework:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd simulation
|
|
||||||
git pull # If using git
|
|
||||||
|
|
||||||
# Reinstall Python dependencies
|
|
||||||
source activate.sh
|
|
||||||
pip install --upgrade pybullet pyinstaller
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Uninstalling
|
## Verification
|
||||||
|
|
||||||
### Remove Virtual Environment
|
After installation, verify packages:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
rm -rf venv/
|
python -c "import pybullet; print('PyBullet OK')"
|
||||||
rm activate.sh
|
python -c "import numpy; print('NumPy OK')"
|
||||||
|
python -c "from PIL import Image; print('Pillow OK')"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Remove ROS 2 (Ubuntu)
|
All should print "OK".
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo apt remove ros-humble-* # or jazzy
|
|
||||||
sudo rm /etc/apt/sources.list.d/ros2.list
|
|
||||||
```
|
|
||||||
|
|||||||
178
setup/install_arch.sh
Executable file
178
setup/install_arch.sh
Executable file
@@ -0,0 +1,178 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# =============================================================================
|
||||||
|
# Drone Simulation - Arch Linux Installation Script
|
||||||
|
# =============================================================================
|
||||||
|
# Installs PyBullet and Python dependencies
|
||||||
|
# ROS 2 requires AUR (optional - not needed for standalone mode)
|
||||||
|
#
|
||||||
|
# Usage: ./install_arch.sh
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "=============================================="
|
||||||
|
echo " Drone Simulation - Arch Linux Installation"
|
||||||
|
echo "=============================================="
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Get script directory and project root
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||||
|
VENV_DIR="$PROJECT_ROOT/venv"
|
||||||
|
|
||||||
|
echo "[INFO] Project root: $PROJECT_ROOT"
|
||||||
|
echo "[INFO] Virtual environment: $VENV_DIR"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Step 1: System Dependencies
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "[STEP 1/5] Installing system dependencies..."
|
||||||
|
|
||||||
|
sudo pacman -Syu --noconfirm
|
||||||
|
sudo pacman -S --needed --noconfirm \
|
||||||
|
python \
|
||||||
|
python-pip \
|
||||||
|
python-virtualenv \
|
||||||
|
base-devel \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
mesa \
|
||||||
|
libglvnd
|
||||||
|
|
||||||
|
echo "[INFO] System dependencies installed"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Step 2: Install AUR Helper (yay) - Optional for ROS 2
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "[STEP 2/5] Checking AUR helper..."
|
||||||
|
|
||||||
|
if command -v yay &> /dev/null; then
|
||||||
|
echo "[INFO] yay already installed"
|
||||||
|
HAS_YAY=true
|
||||||
|
else
|
||||||
|
echo "[INFO] Installing yay (AUR helper)..."
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
if [ -d "yay" ]; then
|
||||||
|
rm -rf yay
|
||||||
|
fi
|
||||||
|
git clone https://aur.archlinux.org/yay.git
|
||||||
|
cd yay
|
||||||
|
makepkg -si --noconfirm
|
||||||
|
cd "$PROJECT_ROOT"
|
||||||
|
|
||||||
|
HAS_YAY=true
|
||||||
|
echo "[INFO] yay installed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Step 3: Create Python Virtual Environment
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "[STEP 3/5] Creating Python virtual environment..."
|
||||||
|
|
||||||
|
if [ -d "$VENV_DIR" ]; then
|
||||||
|
rm -rf "$VENV_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
python -m venv "$VENV_DIR"
|
||||||
|
echo "[INFO] Virtual environment created at: $VENV_DIR"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Step 4: Install Python Dependencies
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "[STEP 4/5] Installing Python dependencies..."
|
||||||
|
|
||||||
|
source "$VENV_DIR/bin/activate"
|
||||||
|
pip install --upgrade pip
|
||||||
|
|
||||||
|
if [ -f "$PROJECT_ROOT/requirements.txt" ]; then
|
||||||
|
echo "[INFO] Installing from requirements.txt..."
|
||||||
|
pip install -r "$PROJECT_ROOT/requirements.txt"
|
||||||
|
else
|
||||||
|
echo "[INFO] Installing packages manually..."
|
||||||
|
pip install pybullet numpy pillow pyinstaller
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[INFO] Python packages installed"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Step 5: Create Activation Script
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "[STEP 5/5] Creating activation script..."
|
||||||
|
|
||||||
|
cat > "$PROJECT_ROOT/activate.sh" << 'EOF'
|
||||||
|
#!/bin/bash
|
||||||
|
# Drone Simulation - Environment Activation (Arch Linux)
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# Try to source ROS 2 if available (from AUR)
|
||||||
|
if [ -f "/opt/ros/humble/setup.bash" ]; then
|
||||||
|
source /opt/ros/humble/setup.bash
|
||||||
|
echo "[OK] ROS 2 humble sourced"
|
||||||
|
elif [ -f "/opt/ros/jazzy/setup.bash" ]; then
|
||||||
|
source /opt/ros/jazzy/setup.bash
|
||||||
|
echo "[OK] ROS 2 jazzy sourced"
|
||||||
|
else
|
||||||
|
echo "[INFO] ROS 2 not found - standalone mode available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Activate Python venv
|
||||||
|
if [ -f "$SCRIPT_DIR/venv/bin/activate" ]; then
|
||||||
|
source "$SCRIPT_DIR/venv/bin/activate"
|
||||||
|
echo "[OK] Python venv activated"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set Gazebo model path if available
|
||||||
|
export GZ_SIM_RESOURCE_PATH="$SCRIPT_DIR/gazebo/models:$GZ_SIM_RESOURCE_PATH"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Environment ready! Run:"
|
||||||
|
echo " python standalone_simulation.py"
|
||||||
|
echo ""
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod +x "$PROJECT_ROOT/activate.sh"
|
||||||
|
echo "[INFO] Created: $PROJECT_ROOT/activate.sh"
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Verification
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "Verifying installation..."
|
||||||
|
|
||||||
|
source "$PROJECT_ROOT/activate.sh"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Checking Python packages:"
|
||||||
|
python -c "import pybullet; print(' PyBullet: OK')" || echo " PyBullet: FAILED"
|
||||||
|
python -c "import numpy; print(' NumPy: OK')" || echo " NumPy: FAILED"
|
||||||
|
python -c "from PIL import Image; print(' Pillow: OK')" || echo " Pillow: FAILED"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=============================================="
|
||||||
|
echo " Installation Complete!"
|
||||||
|
echo "=============================================="
|
||||||
|
echo ""
|
||||||
|
echo "Quick start:"
|
||||||
|
echo " source activate.sh"
|
||||||
|
echo " python standalone_simulation.py"
|
||||||
|
echo ""
|
||||||
|
echo "With moving rover:"
|
||||||
|
echo " python standalone_simulation.py --pattern circular --speed 0.3"
|
||||||
|
echo ""
|
||||||
|
echo "=============================================="
|
||||||
|
echo " Optional: Install ROS 2 from AUR"
|
||||||
|
echo "=============================================="
|
||||||
|
echo ""
|
||||||
|
echo "If you need ROS 2 for the full simulation mode:"
|
||||||
|
echo " yay -S ros-humble-desktop"
|
||||||
|
echo " yay -S ros-humble-ros-gz"
|
||||||
|
echo ""
|
||||||
|
echo "Then use simulation_host.py + ros_bridge.py + controllers.py"
|
||||||
|
echo ""
|
||||||
@@ -27,7 +27,7 @@ class StandaloneSimulation:
|
|||||||
|
|
||||||
DRONE_MASS = 1.0
|
DRONE_MASS = 1.0
|
||||||
DRONE_SIZE = (0.3, 0.3, 0.1)
|
DRONE_SIZE = (0.3, 0.3, 0.1)
|
||||||
DRONE_START_POS = (0.0, 0.0, 5.0)
|
DRONE_START_POS = (10.0, 0.0, 5.0)
|
||||||
|
|
||||||
THRUST_SCALE = 15.0
|
THRUST_SCALE = 15.0
|
||||||
PITCH_TORQUE_SCALE = 2.0
|
PITCH_TORQUE_SCALE = 2.0
|
||||||
|
|||||||
Reference in New Issue
Block a user