Ask Your Question
2

change publish rate of a topic

asked 2014-10-07 13:36:21 -0600

DevonW gravatar image

updated 2014-10-07 15:11:25 -0600

Is there any way to change the rate at which messages are published?

Edit: To update with more information. I would like to know all ways to throttle a node without using programming practices that don't involve the ROS Api. E.g nothing that does (if loop_count % 5) -> Publish(msg)

  1. How to throttle the topic via roslaunch
  2. via command line ROS commands
  3. via ROS api

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2014-10-07 14:30:28 -0600

gvdhoorn gravatar image

updated 2014-10-08 03:30:50 -0600

Sure there is, but it depends on what you really want to do: is this in your own node (read: own code), are you trying to throttle an existing node, or something else?

Please update your question with some more information.


Edit:

1 . How to throttle the topic via roslaunch

Your statement is a bit ambiguous (what should roslaunch do in your opinion?), but if starting another node is acceptable, then I think the throttle or drop nodes from topic_tools should work for you.

2 . via command line ROS commands

Afaik, no such thing exists. That would probably have to rely on a built-in throttling capability, which doesn't exist at the moment.

3 . via ROS api

Personally, I always think of topics & services as the ROS API, but I think you're referring to the functionality exposed by the C++/Python/X client libraries. See my comment on your 2nd bullet. There is no direct support for expressing don't-publish-this-at-more-than-X-hz right now.

[..] E.g nothing that does (if loop_count % 5) -> Publish(msg)

Do these options fall into that category?

  1. use a ros::Rate with an appropriate period, see C++/Time - Sleeping and Rates. This obviously only works if your node is a source, or if you can somehow coalesce all messages received during r.sleep(), and base your own publications on that coalesced state.
  2. use ros::Timer with an appropriate period, see C++/Timers. You'll have to deal with similar issues as with ros::Rate though.
  3. use if ((now() - previous_) > desired_): admittedly primitive, but at least time-based (in contrast to your counting example) and the ROS C++ API supports it easily.

Finally, throttling / rate limiting / any kind of QoS will be much easier to achieve in ROS2.0: one of the fundamental properties of DDS middleware is their support for QoS policies, and any system built on top of such a middleware should be able to exploit that.


PS: this has been asked before, see (for instance):

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-10-07 13:36:21 -0600

Seen: 7,329 times

Last updated: Oct 08 '14