Tools & simulation · topic G1 · 30 hours
Gazebo (gz-sim) & simulation engineering
What cannot run in simulation will definitely run worse on the real robot. Gazebo is the default simulator of the ROS ecosystem: worlds, sensors, plugins, and bridging all live here. Learning it gives you a lab that costs nothing and never crashes.
What to learn
- gz-sim and gazebo-classic are two different things: the new line is named after releases (Garden / Harmonic / Ionic), with completely changed APIs and plugin mechanisms — half the old tutorials online are unusable
- SDF is the native simulation format; URDF is only a subset. xacro handles reuse, sdformat handles conversion, and conversion loses information
- Three key numbers in a world file: physics step size (default 1 ms), solver iterations, and real-time factor RTF
- Sensor plugins and noise models: gpu_lidar, camera, imu, contact. Gaussian noise is not realistic noise (the real thing has bias, color, and dropped frames)
- Topic and clock bridging with ros_gz_bridge: /clock, parameter bridges, bidirectional bridges — pick the wrong direction and you talk to yourself
- System plugins (gz::systems): DiffDrive, JointStatePublisher, JointController, ApplyLinkWrench
- Performance: four reasons RTF drops to 0.3 — rendering, sensor resolution, step size, and too many robots in the scene; running headless with -s is standard practice
The lesson · plain words
Gazebo (gz-sim) is the default simulator of the ROS ecosystem: same origin as ROS, a complete plugin system, and SDF as the standard format. Its problem is «engineering»: it runs slow, tunes poorly, and does not reproduce — this page is about getting those three things under control.
RTF: the health metric of a simulation
RTF (real-time factor) = sim time / wall time. Watch the figure: physics stepping + sensor update + render stack into one cycle; past 16 ms (60 Hz) it cannot keep up with real time — never use sim results with RTF < 0.95 for acceptance testing.
Three levers for speed: cut rendering frequency (only headed mode needs it), lower sensor update rates (30 Hz camera, do not run 60), and increase the physics step (within what contact stability allows, see F1).
Interactive figure · drag it and see
Lockstep and sync: everything about sim time
The simulator has its own clock (the /clock topic); every node must use ROS time (D13) — mix it with «real time» and all your timing falls apart. Lockstep mode: release one control beat per sim step, preserving causal order.
Fixed random seed + fixed initial pose + recorded /clock = a reproducible simulation experiment. Benchmark a sim without these three and you are rolling dice.
SDF/URDF and the plugin system
URDF describes the robot structure (used by rviz and kinematics); SDF describes the simulation world (lighting, terrain, physics parameters). Gazebo plugins bridge the two: differential-drive plugin, camera plugin, lidar plugin — every sensor's noise model is configurable inside the plugin.
Engineering tip: put «world file + models + plugin config» in version control, one launch file starts everything. How versioned your sim config is decides whether it is an asset or a liability.
How deep to go
Build a minimal sim environment with a differential base + camera + lidar; check RTF and apply the speed levers; explain how /clock relates to ROS time. Do these three and the sim integration of Nav2/MoveIt (G4) becomes a downhill walk.
Three questions — do you really get it?
1. What does RTF = 0.8 mean?
- ASimulation accuracy is 80%
- BSim time runs slower than wall time: 1 real second runs 0.8 seconds of sim
- CCPU usage is 80%
Show answer
B. RTF < 1 means «slower than real time»; results from such a sim are distorted for validation and training alike. Speed it up before anything else.
2. Which clock should every node in a simulation use?
- AThe system wall clock
- BROS time (driven by /clock)
- CThe steady clock
Show answer
B. Everything driven by /clock keeps pause/fast-forward/replay semantically consistent (D13).
3. The usual first cut for speeding up a simulation is?
- AUpgrade the CPU
- BLower rendering and sensor rates (in headed scenarios)
- CPush the physics step to the edge of explosion
Show answer
B. Rendering and sensors are the biggest cost with controllable accuracy impact. The physics step needs care (F1).
Keep going deeper
Links without a marker stay on this site; the rest point to the Chinese edition until its translation batch lands.
How it fails in the field
- PID tuned in Gazebo starts oscillating on the real robot: simulation has no current-loop bandwidth limit, no backlash, no 1 ms communication delay, so gains can run 2–3× higher
- Adding Gaussian noise to sensors and calling it realistic — the policy collapses the moment it touches hardware. The shape of the noise distribution matters more than the variance
- Running the sim with the GUI gives RTF 0.4, so you tune all control parameters «slow» — and every one of them is wrong on real hardware
You have learned enough when
The Chinese edition carries the full topic page for Gazebo (gz-sim) & simulation engineering, including the complete outline, depth requirements per career track, and further derivations: robotguide.dev/k/G1/.