Gazebo | Ignition | Community
Ask Your Question

How to control subscriber rate in Gazebo plugin

asked 2020-04-29 01:29:45 -0500

raghavthakar gravatar image

Hi! I have made a C++ Gazebo plugin that simply prints the Twist data it is receiving from a topic. The rate of publishing on the topic by a node has been fixed by me. Is there any way in which I can control the OnUpdate function in the plugin to match the frequency of publishing?

Here's my plugin: C:\fakepath\

Any help would be greatly appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-04-29 05:08:33 -0500

kumpakri gravatar image

You can bind the OnUpdate function to different Event or timer.

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

The ConnectWorldUpdateBegin event happend on every timestep.

There should be a way how to use the ros Timer event to call your function. I made it work once, but don't have the working code around any longer.

Or you can use the OnUpdate function as you have now, just check for the time elapsed from the last time you published. That is the approach I see most often in Gazebo plugins.

edit flag offensive delete link more


This was very helpful! Thank you so much!

raghavthakar gravatar imageraghavthakar ( 2020-05-01 08:13:09 -0500 )edit

Question Tools

1 follower


Asked: 2020-04-29 01:29:45 -0500

Seen: 182 times

Last updated: Apr 29 '20