Docs and Controllers Update

This commit is contained in:
2026-01-02 07:53:44 +00:00
parent 72f85c37a5
commit 61c47f82fc
8 changed files with 289 additions and 208 deletions

View File

@@ -1,13 +1,15 @@
# PyBullet Simulation
# PyBullet Simulation Guide
Running the GPS-denied drone simulation with PyBullet.
Running the GPS-denied drone simulation with PyBullet physics engine.
## Standalone Mode (Recommended)
## Standalone Mode (Single Terminal - Any Platform)
No ROS 2 required! Single terminal:
No ROS 2 required! Works on Windows, macOS, and Linux:
```bash
source activate.sh
source activate.sh # Linux/macOS
. .\activate.ps1 # Windows
python standalone_simulation.py --pattern circular --speed 0.3
```
@@ -24,9 +26,9 @@ Options:
---
## ROS 2 Mode (2 Terminals)
## ROS 2 Mode (Two Terminals)
For distributed or remote simulation:
For distributed or remote simulation with ROS 2:
**Terminal 1 - Simulator:**
```bash
@@ -40,6 +42,16 @@ source activate.sh
python run_bridge.py --pattern circular --speed 0.3
```
### How It Works
1. `simulation_host.py` runs PyBullet physics and listens on UDP port 5555
2. `run_bridge.py` starts:
- `ROS2SimulatorBridge` - connects ROS topics to UDP
- `DroneController` - your landing algorithm
- `RoverController` - moves the landing pad
The rover position is sent to the simulator, so both drone AND rover move!
### Remote Setup
Run simulator on one machine, controllers on another:
@@ -56,25 +68,32 @@ python run_bridge.py --host 192.168.1.100 --pattern circular
---
## Building Standalone Executable
## Configuration
Create a distributable executable:
All parameters are configurable in `config.py`:
```bash
source activate.sh
```python
DRONE = {
"mass": 1.0,
"start_position": (0.0, 0.0, 5.0),
"thrust_scale": 15.0,
...
}
# Build standalone simulation (recommended)
python build_exe.py
ROVER = {
"start_position": (0.0, 0.0, 0.15),
"default_pattern": "circular",
"default_speed": 0.5,
...
}
# Build simulation_host
python build_exe.py simulation_host
# Build all
python build_exe.py all
CONTROLLER = {
"Kp_z": 0.5,
"Kd_z": 0.3,
...
}
```
Executables are created in `dist/`.
---
## Simulation Parameters
@@ -83,18 +102,19 @@ Executables are created in `dist/`.
|-----------|-------|
| Physics Rate | 240 Hz |
| Telemetry Rate | 24 Hz |
| Drone Mass | 1.0 kg |
| Drone Mass | 1.0 kg (configurable) |
| Rover Mass | Static (kinematic) |
| UDP Port | 5555 (commands), 5556 (telemetry) |
## GPS-Denied Sensors
| Sensor | Description |
|--------|-------------|
| IMU | Orientation, angular velocity |
| Altimeter | Barometric altitude, vertical velocity |
| Velocity | Optical flow estimate |
| Camera | 320x240 downward JPEG image |
| Landing Pad | Vision-based relative position |
| **IMU** | Orientation (roll, pitch, yaw), angular velocity |
| **Altimeter** | Altitude above ground, vertical velocity |
| **Velocity** | Estimated horizontal velocity (x, y, z) |
| **Camera** | 320x240 downward-facing JPEG image |
| **Landing Pad** | Vision-based relative position when in camera FOV |
## Troubleshooting
@@ -111,15 +131,33 @@ ssh -X user@host
### Drone flies erratically
Reduce control gains in `drone_controller.py`:
Reduce control gains in `config.py`:
```python
Kp = 0.3
Kd = 0.2
CONTROLLER = {
"Kp_z": 0.3,
"Kd_z": 0.2,
"Kp_xy": 0.2,
"Kd_xy": 0.1,
}
```
### Camera image not appearing
Install Pillow:
```bash
pip install pillow
pip install pillow numpy
```
### Rover not moving (ROS 2 mode)
Ensure `run_bridge.py` is used (not `ros_bridge.py` directly).
The rover controller must be running to send position updates.
### WSL2 GUI issues
Set display scaling:
```bash
export GDK_DPI_SCALE=1.0
export QT_SCALE_FACTOR=1.0
python standalone_simulation.py
```