Simulation Speed in Gazebo#

Simulation Parameters#

By default, Gazebo simulates the world as fast as it can. The current simulation speed can be observed by the real time factor shown in the Gazebo GUI. A factor of one means the simulation is run in real time, a lower factor means it runs slower.

Since Gazebo uses all of the CPU resources by default, it might be desirable to limit the real time factor to a fixed, lower value. However, when using the (default) ODE physics engine, the factor cannot be set directly, but is rather computed by two other values. The first is the max_step_size (default: 0.001), determining the time in the simulation (in s) to be simulated in one step. The second value is the real_time_update_rate (default: 1000), which determines the minimum time period (in Hz) after which the next simulation step is triggered. The multiplication of these two values is the real_time_factor, which results in a default real time factor of 1, i.e., the simulation never runs faster than real time.

These values must be set in Gazebo, which stores it in world files. Below is an example of an empty time-limited simulation world.

<?xml version="1.0" ?>
<sdf version="1.5">
  <world name="default">
    <!-- A global light source -->
    <include>
      <uri>model://sun</uri>
    </include>
    <!-- A ground plane -->
    <include>
      <uri>model://ground_plane</uri>
    </include>
    <physics name='default_physics' default='0' type='ode'>
<!--  the max step size is set to 0.001 by default. -->
<!--  When increasing it, the simulation quality may suffer. -->
      <max_step_size>0.002</max_step_size>
<!--  this factor actually is computed by multiplying the other two -->
      <real_time_factor>0.2</real_time_factor>
      <real_time_update_rate>100</real_time_update_rate>
    </physics>
  </world>
</sdf>

Controlling Simulation Speed in panda_simulation#

The panda_simulation package contains a parameter slow_simulation (default: true), which sets the time factor to 0.2 using the configuration shown above. Note that this is done by selecting a modified version of the default empty_world, so when using different worlds, these must be configured accordingly.

To run the simulation with the default speed, set the value of slow_simulation to false when launching.

roslaunch panda_simulation simulation.launch slow_simulation:=false