96 lines
1.9 KiB
Markdown
96 lines
1.9 KiB
Markdown
# Gazebo Simulation
|
|
|
|
Running the GPS-denied drone simulation with Gazebo (Linux only).
|
|
|
|
## Quick Start (2 Terminals)
|
|
|
|
**Terminal 1 - Start Gazebo:**
|
|
```bash
|
|
source activate.sh
|
|
gz sim gazebo/worlds/drone_landing.sdf
|
|
```
|
|
|
|
**Terminal 2 - Run Controllers:**
|
|
```bash
|
|
source activate.sh
|
|
python run_gazebo.py --pattern circular --speed 0.3
|
|
```
|
|
|
|
## 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"'
|
|
```
|
|
|
|
## GPS-Denied Sensors
|
|
|
|
The `run_gazebo.py` script provides the same sensor interface as PyBullet:
|
|
|
|
| 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` | `Twist` | Velocity commands |
|
|
| `/model/drone/odometry` | `Odometry` | Drone state |
|
|
| `/drone/camera` | `Image` | Camera images |
|
|
|
|
## Headless Mode
|
|
|
|
Run without GUI:
|
|
|
|
```bash
|
|
gz sim -s gazebo/worlds/drone_landing.sdf
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Model not found
|
|
|
|
Set the model path:
|
|
```bash
|
|
export GZ_SIM_RESOURCE_PATH=$PWD/gazebo/models:$GZ_SIM_RESOURCE_PATH
|
|
```
|
|
|
|
### Drone falls immediately
|
|
|
|
Enable the velocity controller:
|
|
```bash
|
|
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
|
|
```
|