3.1 KiB
3.1 KiB
Gazebo Simulation
Running the GPS-denied drone simulation with Gazebo (Linux only).
Quick Start (2 Terminals)
Terminal 1 - Start Gazebo:
source activate.sh
gz sim gazebo/worlds/drone_landing.sdf
Terminal 2 - Run Controllers:
source activate.sh
python run_gazebo.py --pattern circular --speed 0.3
Options
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:
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:
gz sim -s gazebo/worlds/drone_landing.sdf
ROS 2 Launch File (Advanced)
Location: gazebo/launch/drone_landing.launch.py
This launch file automates Gazebo startup for ROS 2 integration:
- Starts Gazebo with the world
- Spawns the drone automatically
- Starts
ros_gz_bridgeto connect topics
Option 1: Direct Launch (Recommended)
Run the launch file directly with ros2 launch:
source activate.sh
ros2 launch gazebo/launch/drone_landing.launch.py
Then in another terminal, run just the controllers:
source activate.sh
python controllers.py --pattern circular
Option 2: Include in Your ROS 2 Package
If you have a ROS 2 package, copy the launch file and use:
ros2 launch my_drone_package drone_landing.launch.py
Launch Arguments
| Argument | Default | Description |
|---|---|---|
use_sim_time |
true |
Use Gazebo clock |
headless |
false |
Run without GUI |
ros2 launch gazebo/launch/drone_landing.launch.py headless:=true
Topics Bridged by Launch File
| ROS 2 Topic | Description |
|---|---|
/drone/cmd_vel |
Velocity commands |
/model/drone/odometry |
Drone state |
/drone/imu |
IMU sensor |
/clock |
Simulation time |
Troubleshooting
Model not found
Set the model path:
export GZ_SIM_RESOURCE_PATH=$PWD/gazebo/models:$GZ_SIM_RESOURCE_PATH
Drone falls immediately
Enable the velocity controller:
gz topic -t /drone/enable -m gz.msgs.Boolean -p 'data: true'
"Cannot connect to display"
Use headless mode or WSLg:
# Headless
gz sim -s gazebo/worlds/drone_landing.sdf
# Or ensure DISPLAY is set
export DISPLAY=:0