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

Why does ROS have nodes?

asked 2017-03-17 16:19:42 -0500

cpagravel gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-03-17 16:52:22 -0500

ahendrix gravatar image

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.

edit flag offensive delete link more

Comments

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).

cpagravel gravatar image cpagravel  ( 2017-03-17 18:30:31 -0500 )edit
1

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 ..

gvdhoorn gravatar image gvdhoorn  ( 2017-03-18 05:25:08 -0500 )edit
1

.. 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.

gvdhoorn gravatar image gvdhoorn  ( 2017-03-18 05:26:30 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-03-17 16:19:42 -0500

Seen: 278 times

Last updated: Mar 17 '17