ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
4

Performance cost of rostopic?

asked 2016-07-06 13:22:45 -0500

jacksonkr_ gravatar image

updated 2016-07-06 13:24:00 -0500

Is there a performance cost of publishing a rostopic even if no networked or local machine is pulling from it?

I'm trying to cut down on performance loss in any way I can, is it possible to disable rostopics that go unused? Is this even worth it?

Tangential question: Is there a top or System Monitor for ros ?

edit retag flag offensive close merge delete

Comments

I don't know the full answer, but I'm pretty sure it depends on the topic. Some are on-demand and some aren't. http://answers.ros.org/question/37869...

curranw gravatar image curranw  ( 2016-07-06 14:35:52 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
4

answered 2016-07-06 14:42:12 -0500

ahendrix gravatar image

Topics (by themselves) have very little overhead; if there are no subscribers to a topic, there is no data transferred and therefore no bandwidth used.

The place where I've seen the largest performance penalty for topics that aren't subscribed to is the computation of the data; for example if your node is processing images, in a simple implementation the node performs the image computation even if the result is not used.

Publishing messages incurs a very small amount of processing to serialize the message, but this is negligible for small messages (<1MB in size).

The common solution that I've seen to both of these is to check if there are any subscribers on a topic before publishing, and skipping the processing and publish steps if there are no subscribers. (In C++ you can use the getNumSubscribers() call on the publisher object)

ROS doesn't provide any direct tools for analyzing the performance hit of the library itself. If you're interested in analyzing CPU bottlenecks, you can run your node in a profiler.

If you're interested in network bandwidth usage, there are lots of good network analysis tools like iptraf and iftop. (nethogs looks interesting too, but I haven't used it personally)

edit flag offensive delete link more

Comments

A very thorough answer. Thanks @ahendrix!

jacksonkr_ gravatar image jacksonkr_  ( 2016-07-07 11:34:55 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-06 13:22:45 -0500

Seen: 1,958 times

Last updated: Jul 06 '16