Ubuntu Linux for Robotics · Lesson 61 of 96
Gazebo plugins
System plugins, the sensors system, and connecting Gazebo to ros2_control.
Estimated time · 45–75 min
Learning goals
What you will understand
- Explain gazebo plugins in your own words
- Use it in a small workstation example
- Verify the result instead of assuming it worked
Understand the idea first
The mental model
Plugins add behaviour to the simulation: world plugins provide physics and rendering, sensor plugins create lidars, cameras and IMUs, and model plugins drive joints (the DiffDrive plugin or gz_ros2_control). Plugins are described in the world SDF or in <gazebo> tags of the URDF.
If a sensor publishes nothing, the most likely cause is a missing system plugin (for example the sensors system in the world). Use gz topic -l to see what exists and gz topic -e -t /topic to read a Gazebo message directly, then bridge only the topics ROS 2 needs.
Guided lesson
Work through these steps
- 1.
Open a terminal and record the current state before changing anything.
- 2.
Read the gazebo plugins commands and predict what each one does.
- 3.
Run the commands one at a time and compare each output with your prediction.
- 4.
Write the commands that worked in a setup note you can repeat later.
Worked example
Read it before you run it
gz topic -l
# List all Gazebo topics.
gz topic -e -t /world/empty/stats
# Print the simulator's own statistics.
gz service -l | head
# List Gazebo services (spawn, pause, and so on).
ros2 pkg list | grep gz_ros2_control
# Confirm the ros2_control plugin package is installed.
gz sim -v 4 world.sdf 2>&1 | grep -i plugin
# Check the log for plugin loading messages.What the example is doing
- 1.Lines without sudo only inspect or change files you own; sudo authorizes a system-wide change.
- 2.Read command output before moving to the next line. Stop if names, versions, disks, or paths differ from the lesson.
- 3.Comments beginning with # explain safety checks and are not executed by the shell.
Watch it run · Mobile robot
See what this code does
The terminal types this lesson's practice solution and runs it. The scene shows the kind of robot behaviour that code drives. It plays by itself and loops.
Demo for Gazebo plugins. Expected result: The list contains the topics of the loaded plugins
Practice code
Now type it yourself
Open a terminal, run the starter line by line (or save it as practice.sh and run bash practice.sh), and replace every TODO with your own command.
# TODO: list all Gazebo topicsExpected output
The list contains the topics of the loaded pluginsStuck? Show the full solution (try it yourself first)
gz topic -lExpected result
How you know it worked
- Each command completes without an unexplained error.
- Your notes contain the command, the important output, and what it proves.
Practical exercise
Apply the lesson
Add the sensors system plugin to a world, add a lidar sensor to a robot, verify the topic with gz topic, and remove the plugin to see the topic disappear.
Before you continue
- You recorded the starting state
- Every command and output is understood
- The change can be repeated from your notes
If something goes wrong
Check ownership and permissions first. Do not add sudo unless the command changes a documented system location.
Check spelling, Ubuntu version, enabled repositories, and whether the previous installation command succeeded.