Understanding ROS nodelets

Waleed Mansoor
3 min readApr 3, 2018

--

ROS provides platform to develop a distributed and highly independent modular system to control a robot. The constituent modules i-e nodes have limited knowledge of other nodes in system and communicate over TCP (or UDP) via standard messages i-e topics. This is a great strength and enables rapid and clean development and high reusability.

This does come with its performance drawback as communication must be done over network infrastructure which can slow down things considerably especially if the message consists of huge sized data like video streams or lidar scan.

To overcome this efficiency issue and still provide the same benefits of standardized message passing infrastructure ROS presents the concept of nodelets.

Nodelets let you use the same interface of subscribing and publishing to topics. However when a nodelet subscribes or publishes to topic in the same nodelet manager, instead of message being passed over TCP/IP only a C++ boost pointer to message is passed. This gets rids of the message passing inefficiency while maintaining the modular nature of ros nodes. At moment nodelet only have interface in C++.

How this is accomplished must be understood properly if they are to be utilized appropriately.

  1. Pluginlib: Nodelets are based on concept of plugins where a libary (so/dll) is loaded at runtime by the executable and provides enhanced functionality. The interface to be used by plugin is predefined and plugin calls the predefined function callbacks to provide custom facility. ROS pluginlib should be properly understood to understand nodelets. http://wiki.ros.org/pluginlib
  2. Nodelet manager: After pluginlib is understood, one finds that nodelets are simple plugins which are loaded at runtime by a ros node. The ros node which can be special default node just to load nodelets and enable their communication or it can be any other node having functionality to load nodelets. The special node providing this facility is http://wiki.ros.org/nodelet
  3. The nodelets can subcribe to topics just like normal nodes. However if topic is published by nodelet handled by SAME nodelet manager then that is passed as a pointer. However if it is published by another nodelet in another manager or by any other standard node then communication is same as normal ROS nodes.

Implementing Nodelets

To implement nodelets one must basically implement plugin as demonstrated in this pluginlib tutorial http://wiki.ros.org/pluginlib/Tutorials/Writing%20and%20Using%20a%20Simple%20Plugin

This involves defining namespace for nodelet and adding necessary modifications to package.xml and CMakeLists.txt

Understand that publish/subscribe mechanism is identical to nodes.

Nodelets are best run using launch files. Define one nodelet node as manager by passing manager as argument and give it a certain name. Define other nodelet nodes with different name but pass the name of manager node to load argument as explained in

One of good tutorials covering nodelets is

and Kobuki platform uses nodelets heavily

Conclusion

Nodelets are useful construct which can help you in performance critical nodes. However they can be slightly more cumbersome to implement then normal nodes. If performance is not an issue, using standard nodes is advantageous but anywhere performance becomes important nodelets can come to rescue.

--

--