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.