Robotics StackExchange | Archived questions

Nodelet Tutorial and API - How to write a nodelet ?

Hello,

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.

Asked by Confused Lizard on 2019-08-01 11:49:55 UTC

Comments

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?

Asked by gvdhoorn on 2019-08-01 13:04:09 UTC

@gvdhoorn

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.

Asked by Confused Lizard on 2019-08-01 13:28:17 UTC

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

Asked by gvdhoorn on 2019-08-01 13:34:40 UTC

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
    {
        public:
        virtual void onInit();
        void compute_dynamics()
        private:
        // 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.

Asked by Confused Lizard on 2019-08-01 13:50:33 UTC

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.

Asked by gvdhoorn on 2019-08-01 14:15:55 UTC

Answers