0
$\begingroup$

Rosanswers logo

I've read the documentation about nodes and topics, but they just describe what nodes and topics are, not why they are useful. Granted, I'm very new to designing robot source code and I am guessing that there are particular cases when they are needed, I have just yet to see them. I'm currently working for a robotics startup (as an intern) that has a pretty messy code base and I really want to clean it up--but I want to use best practices and a very good design. AFAIK, nodes are useful to support inter process communication. Well, there are many parts in the system I'm looking at and I think they've made too many nodes where there doesn't really need to be. It seems like nodes are being used in place of designing a proper architecture that passes information internally.

Therefore, I'd like to hear the community's opinion on nodes. Should we avoid using them unless absolutely necessary? When are they absolutely necessary? What is the problem with having one monolithic process?


Originally posted by cpagravel on ROS Answers with karma: 156 on 2017-03-17

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

From http://wiki.ros.org/Nodes

The use of nodes in ROS provides several benefits to the overall system. There is additional fault tolerance as crashes are isolated to individual nodes. Code complexity is reduced in comparison to monolithic systems. Implementation details are also well hidden as the nodes expose a minimal API to the rest of the graph and alternate implementations, even in other programming languages, can easily be substituted.

Separate nodes gives better fault tolerance and debugging; it's much easier to see what's broken when a single node is crashing, and the OS prevents nodes from overwriting the memory of other nodes.

Using a pub-sub middleware like ROS also hides the thread/process synchronization that happens in any large, multithreaded system and provides a more obvious way to distribute the processing load across many cores.

Obviously there's a performance hit for serializing and deserializing messages, but for small messages this is negligible. If you're passing around large messages such as images or point clouds, the performance gain from using nodelets outweighs their complexity.

For more best practices, have a look at the ROS Patterns and Best Practices section of the wiki.


Originally posted by ahendrix with karma: 47576 on 2017-03-17

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by cpagravel on 2017-03-17:
Was there ever an instance when you found that putting a piece of code into a separate node was extremely beneficial or mission critical to do? I'd appreciate to hear some personal experience. I'm trying to architect a design which allows for future modularity (which is why I want a feel for nodes).

Comment by gvdhoorn on 2017-03-18:
I would add to @ahendrix's answer that ROS is (a form of a) component based software framework, making CBSE possible. Nodes are just the concrete implementation of the component concept in ROS, which offer services and consume and produce datastreams. Packages then group several such components ..

Comment by gvdhoorn on 2017-03-18:
.. in coherent sets (although guarding the coherency is the responsibility of the author / maintainer, so is not necessarily guaranteed).

My personal experience is that if you see all of ROS as one concrete example of a more abstract conceptual framework (ie: CBSE), things make sense sooner.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.