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

ROS performace as number of topics increase

asked 2014-12-12 11:12:59 -0500

Benny gravatar image

updated 2014-12-12 13:21:29 -0500

ahendrix gravatar image


I am very curious about how the latency and the communication speed decreases as I increase the number of topics. If I have a package creating 20 topic for control. Is that a good idea? I can make this into a single topic with 20 different options inside it.

I dont know If I am clear but I want to know if there are any guidelines on maximum number of topics a node can create/subscribe. What are the best practice in this regard? Any link or suggestion on it would be welcome. I believe rosservice and ros actionlib all use multiple topics underneath. How many topics does a rosservice create?

Thanking you, Benzun

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-12-12 11:43:33 -0500

Wolf gravatar image

I don't think you should bother about the ROS communication speed (ROS will not definitely not die for 20 or even 100 topic). I think you should go more into your system design and look what you need and then implement what you need. E. g. if you have 20 different msgs/ topics you will end up with 20 callback functions on your subscriber side. If you will need to aggregate all the information again of the 20 msgs on your subscriber side before you can start doing some real processing of the information then having 20 topic is probably a bad solution and leaving the information together and publishing one aggregated message would definitelzy be better.

On the other hand if you have on the subscriber side 20 different nodes of which all only need a small part of the information you publish and not your big aggregated information container, then yes well, in this case having 20 different msgs / topic could be a smart approach.

edit flag offensive delete link more


yes part of the problem is good software design but I feel it cannot be done without understanding how ROS behaves. From my understanding you are hand-waving it by saying such delays are insignificant. In a band-limited, computation limited system, it is a huge consideration for design when scaling

Benny gravatar image Benny  ( 2014-12-12 12:04:41 -0500 )edit

If you want to understand how the system works, I suggest you read through the documentation:

tfoote gravatar image tfoote  ( 2015-02-26 13:25:45 -0500 )edit

answered 2014-12-12 13:32:08 -0500

ahendrix gravatar image

I'm agree with @Wolf ; you should design your software in a way that makes sense first, and optimize second.

That said, here are a few details about how ROS is implemented:

ROS topics create a TCP connection for each connection of a topic between a publisher and a subscriber.

The operating system can usually handle a very large number of open sockets (thousands per process), and when communicating between processes that are on the same host, the performance of a TCP connection is comparable to the performance of shared memory.

Actionlib is implemented with topics. ROS services are implemented as a single TCP connection between each client and the server.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-12-12 11:12:59 -0500

Seen: 1,828 times

Last updated: Dec 12 '14