How to control subscriber rate in Gazebo plugin
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.
Asked by raghavthakar on 2020-04-29 01:29:45 UTC
Answers
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.
Asked by kumpakri on 2020-04-29 05:08:33 UTC
Comments
This was very helpful! Thank you so much!
Asked by raghavthakar on 2020-05-01 08:13:09 UTC
Comments