Nodelet Tutorial and API - How to write a nodelet ?

asked 2019-08-01 11:55:08 -0500

Confused Lizard gravatar image

updated 2019-08-01 13:41:30 -0500


I am looking for a complete documentation and/or tutorials with explanation and use-case about ROS nodelet API.

The official doc is very comprehensible and the tutorial has virtually no explanations. And I didn't find any real external resources except "read our code" kind of thing, with little explanations.

Are nodelet really used ? As ROS2 Component are now the new way of communication between processes, I though nodelet were more relevant and in a way, more broadly present in ROS projects but I feel they are hardly referenced or used.

Are they a high level API with very specific use ?

PS: For my use case, I'm looking to use the nodelet API as I am looking to run several process in the same class without having a node for each component of my algorithm. And to make it easier to transition to ROS2 Component.

Project structure: Project Structure

Thank you.

edit retag flag offensive close merge delete


Just for clarification:

I am looking to run several process in the same class

with "process" here, you are referring to operations or groups of operations on data(streams), not actual Operating System processes, correct?

gvdhoorn gravatar imagegvdhoorn ( 2019-08-01 13:04:09 -0500 )edit


Yes, I am referring to operations on data. I have a class with variables. These data are shared by multiples algorithms like illustrated here and some will be streamed for external packages or node for use.

I made a diagram of how I was picturing the ROS project.

Confused Lizard gravatar imageConfused Lizard ( 2019-08-01 13:28:17 -0500 )edit

Please embed the diagram into the question itself, instead of linking to imgur. I've given you sufficient karma for that.

re: your diagram: I'm not sure what you show there is something that nodelets allow you to do (for one thing: services are not supported, only publishers and subscribers). The 'shared' Robot Class (should that be an 'object'?) would also not be how things work with nodelets.

Nodelets are nodes, just mapped onto threads instead of processes (which allows them to share a single memory address space, allowing them to exchange messages using shared memory).

gvdhoorn gravatar imagegvdhoorn ( 2019-08-01 13:34:40 -0500 )edit

The Robot Class inherits of the public class nodelet: all nodes are called within the class Robot (at least from my understanding about nodelet):

my RobotClass.hpp is like it follow (roughly)

namespace robot
    class Robot: public nodelet::Nodelet
        virtual void onInit();
        void compute_dynamics()
        // callback methods
        void callback(cont std_msgs::Float64Ptr input);;
        // nodelet stuff
        ros::NodeHandle private_nh;
        ros::Subscriber _sub_dynamics;
        ros::Publisher _pub_dynamics;
        // state vector
        Eigen::Vector3d pose
        Eigen::Vector3d velocity;
        double command;

Thank you, I though any kind of node were able to be converted into nodelets.

Confused Lizard gravatar imageConfused Lizard ( 2019-08-01 13:50:33 -0500 )edit

I believe the best way to understand nodelets is to see them as "just nodes", but mapped onto threads.

So design your system as a series of nodes, but implement them as nodelets. You then gain zero-copy message transport and very low-latency message exchange.

Thank you, I though any kind of node were able to be converted into nodelets.

they can be, but services (and actions) will not benefit from the zero-copy optimisations.

gvdhoorn gravatar imagegvdhoorn ( 2019-08-01 14:15:55 -0500 )edit