Gazebo | Ignition | Community
Ask Your Question

Can someone explain the role of "ConnectWorldUpdateBegin()" function ?

asked 2018-06-28 07:04:52 -0500

pk gravatar image

Gazebo Version : 7.13.1
Ubuntu 16.04
As a newbie, I tried a lot to understand the use of above function but I am not able to understand it fully. It would be really helpful, if someone can explain it with an example. It would be even nice, if someone can explain line number 143 and 144 in LiftDragPlugin.Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-07-03 10:02:55 -0500

updated 2018-07-05 08:58:16 -0500

lines 143-144 of

this->updateConnection = event::Events::ConnectWorldUpdateBegin(
          std::bind(&LiftDragPlugin::OnUpdate, this));

Short Answer:
This passes your Plugin's Update method (in this case, LiftDragPlugin::OnUpdate) as a callback function to the Gazebo Simulator's Events class instance, allowing Gazebo to call your Plugin's method (LiftDragPlugin::OnUpdate) at every simulation time step.

Long Answer:
- You write a Gazebo Plugin to affect the simulation - in this case the LiftDragPlugin applies rudimentary lift and drag forces to the attached model.
- In order for the LiftDragPlugin to apply these forces in the simulation, it needs to, _at every simulation time step_, 1) determine the attached model's orientation relative to gravity plane, determine model's velocity, etc., 2) carry out some simple lift-drag calculations, and 3) apply the appropriate lift-drag forces.
- Therefore, in your Gazebo Plugin, you create a Update, OnUpdate, RunEverySimulationTimeStep, etc. method - here it's LiftDragPlugin::OnUpdate, that contains the code that should be run at each simulation time step, and you pass that method (or rather a reference to that method) to the Gazebo Simuator's Event class instance as a callback function: event::Events::ConnectWorldUpdateBegin(...).
- Now at each simulation time step, the Gazebo Simulator will call the LiftDragPlugin::OnUpdate method and everybody lives happily ever after.

edit flag offensive delete link more


Thanks a lot for the explanation.

pk gravatar imagepk ( 2018-07-06 23:50:21 -0500 )edit

Question Tools

1 follower


Asked: 2018-06-28 07:04:52 -0500

Seen: 1,944 times

Last updated: Jul 05 '18