Gazebo | Ignition | Community
Ask Your Question
1

Basic question regarding plugin

asked 2013-01-20 03:16:33 -0500

ChengXiang gravatar image

Hi guys. I have basic questions regarding plugins and I am using Gazebo with ROS. Firstly, in the plugin examples given in the tutorial, there is no main function, only class declaration. So how are the functions within the class in the plugin implemented? Is it that all the functions in “public” will be executed?

Secondly, can I know what this piece of code does?

// Listen to the update event. This event is broadcast every
      // simulation iteration.
      this->updateConnection = event::Events::ConnectWorldUpdateStart(
          boost::bind(&ModelPush::OnUpdate, this));

From what I gather, this means that the ModelPush is binded as a function pointer and it will be call every time the world update by receiving a "world update" signal. Am I right?

If so, why is it that in the "Hello world" example (the first tutorial), the print function will executed?

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2013-01-20 13:07:32 -0500

r0nald gravatar image

updated 2013-01-20 13:08:22 -0500

Plugins do not have a main() function, they are objects that are created by the main gazebo process. The print function in the example gets called, because the constructor HelloWorld::HelloWorld() is called when the object is created (really elementary C++ knowledge).

From what I gather, this means that the ModelPush is binded as a function pointer and it will be call every time the world update by receiving a "world update" signal. Am I right?

Almost. The method ModelPush::OnUpdate() of your ModelPush object (this)is called on world update.

edit flag offensive delete link more

Comments

I see. Thanks for clarifying!

ChengXiang gravatar imageChengXiang ( 2013-01-21 06:38:03 -0500 )edit

Question Tools

Stats

Asked: 2013-01-20 03:16:33 -0500

Seen: 609 times

Last updated: Jan 20 '13