3.1 KiB
3.1 KiB
Gazebo Simulation
Running the GPS-denied drone simulation with Gazebo.
Prerequisites
Install Gazebo and ROS-Gazebo bridge:
./setup/install_ubuntu.sh
source activate.sh
Quick Start
Terminal 1 - Start Gazebo:
source activate.sh
gz sim gazebo/worlds/drone_landing.sdf
Terminal 2 - Spawn drone and start bridge:
source activate.sh
# Spawn drone
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:
source activate.sh
python controllers.py --pattern circular --speed 0.3
World Description
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 |
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 |
Headless Mode
Run without GUI:
gz sim -s gazebo/worlds/drone_landing.sdf
Using the Launch File
For ROS 2 packages:
ros2 launch <package_name> drone_landing.launch.py
Troubleshooting
"Cannot connect to display"
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:
gz topic -t /drone/enable -m gz.msgs.Boolean -p 'data: true'
Topics not visible in ROS
Ensure the bridge is running:
python gazebo_bridge.py
Model not found
Set the model path:
export GZ_SIM_RESOURCE_PATH=$PWD/gazebo/models:$GZ_SIM_RESOURCE_PATH
Camera image not in telemetry
Ensure PIL/Pillow is installed:
pip install pillow