Skip to content

ROS 2Units, Frames and Simulation

How a Simulator Steps Time

A simulator advances in fixed steps Δt; the real-time factor is simulated time over wall-clock time.

Not started Jump to practice

Simulators let you test a robot that you have not built, or test a risky move without breaking anything. Gazebo is the simulator most often used with ROS 2.

Key idea

A simulator advances the world in fixed time steps $\Delta t$: compute forces, update speeds, update positions, repeat. The real-time factor is simulated time divided by clock time: below 1 it runs slower than life, above 1 faster.
This picture is a tiny simulation itself: it steps a cart's motion forward in small time steps.

Why it works

Smaller steps follow the true motion more closely but take more work; too large a step can make a simulation blow up. A slow real-time factor does not make the physics wrong, it only takes longer to watch. The catch with all simulation: real motors, friction and sensors differ from the model, so a design must still be tested on hardware.

Worked example: Steps

1 ms steps, 10 s simulated.
  1. $10 / 0.001 = 10{,}000$ steps.

Answer: 10,000 steps.

Common mistake

Thinking a slow simulation gives wrong answers, or that a large time step is always fine.

Try it

Spawn a simple wheeled robot in Gazebo following the ROS 2 and Gazebo tutorials, drive it from the keyboard, and record its odometry topic. Then run your encoder-square test from the Navigation course in simulation and compare the drift with your real robot's.

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 2 XP.

Loading practice…

Builds on

Leads to

This is one of the top rungs of ROS 2 and Simulation.

Sources and further reading