Gazebo | Ignition | Community
Ask Your Question
0

How to control subscriber rate in Gazebo plugin

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

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\my_plugin.cc

Any help would be greatly appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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

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

Comments

This was very helpful! Thank you so much!

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

Question Tools

1 follower

Stats

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

Seen: 197 times

Last updated: Apr 29 '20