Update to Bridges

This commit is contained in:
2026-01-01 01:08:30 +00:00
parent 2b01f636fe
commit 4b44c3de91
9 changed files with 578 additions and 324 deletions

View File

@@ -1,17 +1,8 @@
# Gazebo Simulation
Running the GPS-denied drone simulation with Gazebo.
Running the GPS-denied drone simulation with Gazebo (Linux only).
## Prerequisites
Install Gazebo and ROS-Gazebo bridge:
```bash
./setup/install_ubuntu.sh
source activate.sh
```
## Quick Start
## Quick Start (2 Terminals)
**Terminal 1 - Start Gazebo:**
```bash
@@ -19,86 +10,54 @@ source activate.sh
gz sim gazebo/worlds/drone_landing.sdf
```
**Terminal 2 - Spawn drone and start bridge:**
**Terminal 2 - Run Controllers:**
```bash
source activate.sh
python run_gazebo.py --pattern circular --speed 0.3
```
# Spawn drone
## Options
```bash
python run_gazebo.py --help
Options:
--pattern stationary, linear, circular, square, random
--speed, -s Rover speed in m/s (default: 0.5)
--amplitude, -a Movement amplitude (default: 2.0)
--no-rover Disable rover controller
```
## Spawning the Drone
If the drone isn't in the world, spawn it:
```bash
gz service -s /world/drone_landing_world/create \
--reqtype gz.msgs.EntityFactory \
--reptype gz.msgs.Boolean \
--req 'sdf_filename: "gazebo/models/drone/model.sdf", name: "drone"'
# Start bridge
python gazebo_bridge.py
```
**Terminal 3 - Run controllers:**
```bash
source activate.sh
python controllers.py --pattern circular --speed 0.3
```
## GPS-Denied Sensors
## World Description
The `run_gazebo.py` script provides the same sensor interface as PyBullet:
The `drone_landing.sdf` world contains:
| Object | Description |
|--------|-------------|
| Ground Plane | Infinite flat surface |
| Sun | Directional light with shadows |
| Landing Pad | Green box with "H" marker at origin |
## Drone Model
Quadrotor drone with:
- **Body**: 0.3m × 0.3m × 0.1m, 1.0 kg
- **Rotors**: 4 spinning rotors
- **IMU**: Orientation and angular velocity
- **Camera**: 320x240 downward-facing sensor
- **Odometry**: Position and velocity
### Gazebo Plugins
| Plugin | Function |
|--------|----------|
| MulticopterMotorModel | Motor dynamics |
| MulticopterVelocityControl | Velocity commands |
| OdometryPublisher | Pose and twist |
## Camera System
The drone has a downward-facing camera:
| Property | Value |
|----------|-------|
| Resolution | 320 x 240 |
| FOV | 60 degrees |
| Format | Base64 encoded JPEG |
| Update Rate | 30 Hz (Gazebo) / ~5 Hz (in telemetry) |
| Topic | `/drone/camera` |
| Sensor | Source |
|--------|--------|
| IMU | Gazebo odometry |
| Altimeter | Gazebo Z position |
| Velocity | Gazebo twist |
| Camera | Gazebo camera sensor |
| Landing Pad | Computed from relative position |
## Gazebo Topics
| Topic | Type | Description |
|-------|------|-------------|
| `/drone/cmd_vel` | `gz.msgs.Twist` | Velocity commands |
| `/model/drone/odometry` | `gz.msgs.Odometry` | Drone state |
| `/drone/camera` | `gz.msgs.Image` | Camera images |
| `/drone/imu` | `gz.msgs.IMU` | IMU data |
## GPS-Denied Sensors
The `gazebo_bridge.py` converts Gazebo data to GPS-denied sensor format:
| Sensor | Source |
|--------|--------|
| IMU | Odometry orientation + angular velocity |
| Altimeter | Odometry Z position |
| Velocity | Odometry twist |
| Camera | Camera sensor (base64 JPEG) |
| Landing Pad | Computed from relative position |
| `/drone/cmd_vel` | `Twist` | Velocity commands |
| `/model/drone/odometry` | `Odometry` | Drone state |
| `/drone/camera` | `Image` | Camera images |
## Headless Mode
@@ -108,51 +67,29 @@ Run without GUI:
gz sim -s gazebo/worlds/drone_landing.sdf
```
## Using the Launch File
For ROS 2 packages:
```bash
ros2 launch <package_name> drone_landing.launch.py
```
## Troubleshooting
### "Cannot connect to display"
```bash
export DISPLAY=:0
# or use headless mode
gz sim -s gazebo/worlds/drone_landing.sdf
```
### Drone falls immediately
The velocity controller may need to be enabled:
```bash
gz topic -t /drone/enable -m gz.msgs.Boolean -p 'data: true'
```
### Topics not visible in ROS
Ensure the bridge is running:
```bash
python gazebo_bridge.py
```
### Model not found
Set the model path:
```bash
export GZ_SIM_RESOURCE_PATH=$PWD/gazebo/models:$GZ_SIM_RESOURCE_PATH
```
### Camera image not in telemetry
### Drone falls immediately
Ensure PIL/Pillow is installed:
Enable the velocity controller:
```bash
pip install pillow
gz topic -t /drone/enable -m gz.msgs.Boolean -p 'data: true'
```
### "Cannot connect to display"
Use headless mode or WSLg:
```bash
# Headless
gz sim -s gazebo/worlds/drone_landing.sdf
# Or ensure DISPLAY is set
export DISPLAY=:0
```