Home | Tutorials | Wiki | Issues
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ConnectWorldUpdateBegin vs. ConnectWorldUpdateEnd in model plugins?

As documented in many tutorials and answers.gazebosim.org posts (e.g. this one) model plugins should connect to the WorldUpdateBegin event by registering an update callback using event::Events::ConnectWorldUpdateBegin(...).

As there is also a ConnectWorldUpdateEnd(...) method and from looking at the implementation details in the World::Update() function in World.cc:613 I wonder if it might be better for some model plugins to run at the end of the world update instead of at the beginning? This is especially the case for model plugins that simulate sensors, like the IMU or P3D plugin in the gazebo_plugins package for ROS.

If I understand the implementation of the world update correctly it basically

  1. Updates the sim time
  2. Processes the worldUpdateBegin event
  3. Updates the physics, handles collisions etc.
  4. Processes the worldUpdateEnd event

If this is true then plugins like the gazebo_ros_imu plugin should run after the physics update and have access to the updated model data valid for the current time step to not introduce an delay. It all depends if the physics update at time step t_k integrates over time interval t_(k-1) to t_k or t_k to t_(k+1).

This does not affect sensor plugins like laser or camera as they are triggered by new data being available for the sensor they are attached to. Is there a guarantee that if a sensor runs with an update rate of 500 Hz and the physics engine at 1000 Hz that the measurements represent the world state of exactly every 2nd world update?