Robotics StackExchange | Archived questions

Publishers and Subscribers in one node or two?

Hey there, I was wondering for a fairly number of publishers and subscribers (~50 each), would it be better to put the publishers in one node and the subscribers in another, or is it okay to add all of them in one node?

Asked by mandymandymandy on 2020-03-01 08:03:41 UTC

Comments

Answers

Hi @mandymandymandy,

At the end of the day the only thing you will have will be a set of thread executing publishing tasks or subscribing ones so technically it does not matter. On the other hand, there are important things like keeping the code clean, adjust to ROS standards and organizing properly your project.

If you are OK dealing with the set of subscribers and publishers in the same node go ahead, but take into account that if you split this two sets in two different nodes, technically you will have the same set up but better understanding of your package structure and code.

At least is how I see it, if someone in this community wants to add more background on this kind of problems I will be glad to hear it.

Asked by Weasfas on 2020-03-02 03:10:01 UTC

Comments

When a publisher and subscriber use the same topic both exist inside the same node

This statement is incorrect. Topics and nodes are two completely separate concepts. Publishers and subscribers of the same topic can existing in the same node as well as in separate nodes.

Asked by Dirk Thomas on 2020-03-02 12:15:30 UTC

Well,

That sentenced was extracted direcly from the ROS wiki. But I realise now I misread that line. Thanks for noticing I will update the comment.

Asked by Weasfas on 2020-03-02 12:44:06 UTC

Also take into consideration that more nodes -> bigger system. Going from one node to two nodes does not matter much. Going from one node to 10 or 100 nodes will have significant impact. This impact will be bigger in older versions of ROS2 because of this issue https://discourse.ros.org/t/reconsidering-1-to-1-mapping-of-ros-nodes-to-dds-participants . Future releases will probably deal with this better.

I mention this to clarify that although you won't see a difference at network level (same amount of publishers, subscribers, same rates, same data) the underlying DDS setup and system will be very different and this will have a performance impact.

Asked by MCornelis on 2020-03-04 05:19:08 UTC