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

Trying to understand nodelets

asked 2020-07-25 09:44:02 -0600

Kansai gravatar image

I am having a very hard time trying to understand nodelets, using the documents and tutorials. However after much I have been able to do most of what is written in the tutorial "Running a nodelet"

I have done what is written til part 3. I don't understand what is going on on part 4.Using with roslaunch files (I have already study launch files)

  <node pkg="nodelet" type="nodelet" name="standalone_nodelet"  args="manager"/>

  <node pkg="nodelet" type="nodelet" name="Plus"
        args="load nodelet_tutorial_math/Plus standalone_nodelet">
    <remap from="/Plus/out" to="remapped_output"/>
  <rosparam param="Plus2" file="$(find nodelet_tutorial_math)/plus_default.yaml"/>
  <node pkg="nodelet" type="nodelet" name="Plus2" args="load nodelet_tutorial_math/Plus standalone_nodelet">
    <rosparam file="$(find nodelet_tutorial_math)/plus_default.yaml"/>
  <node pkg="nodelet" type="nodelet" name="Plus3" args="standalone nodelet_tutorial_math/Plus">
    <param name="value" type="double" value="2.5"/>
    <remap from="Plus3/in" to="Plus2/out"/>

I see 4 nodes (one of it the nodelet manager) being run. Can someone explain to me:

  1. What is going on here?
  2. why in the third node rosparam is written twice? (one inside and one outside the node)
  3. Why the rosparam part don't use the "command" option like <rosparam command="load" file="$(find teleopbot)/param2.yaml" /> but instead only use file?
  4. How, after calling this launch file, can I see the nodes (nodelets) doing something??

And finally can someone explain to me the following found here

(Basic usage)

nodelet load pkg/Type manager - Launch a nodelet of type pkg/Type on manager manager

nodelet standalone pkg/Type - Launch a nodelet of type pkg/Type in a standalone node

What does launch on manager and launch standalone means, and what are the differences.

Frankly trying to understand nodelets is really hard, and I have not found any resource example or tutorial that explains these

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-07-25 13:44:19 -0600

Julian98 gravatar image

updated 2020-07-25 13:48:16 -0600

The basic idea of nodelets is to avoid the overhead of inter process communication (with serializing/deserializing data, ROS is using TCP to transfer the data between the nodes as they may be on different computers on the same network) that occurs, when you have nodes (which are separate processes) communcating with each other via messages. This overhead can be a big problem when dealing with images and sending them between multiple nodes for example. Nodelets are classes deriving from the nodelet::Nodelet class exported from the package and therefore implement the interface the nodelet manager needs to load them. One nodelet manager loads multiple nodelets into the same process, therefore avoiding the overhead, because now one can simply pass around pointers to the raw data instead of messages.

To answer your questions:

  1. The first entry in the launchfile launches a nodelet manager as indicated by the single argument "manager", the node/process that is able to load in nodelets. The subsequent <node> entries load different nodelets into this nodelet manager. You do that by calling the nodelet package again and the passing the nodelet you want to load in as an argument followed by the nodelet manager's name (here it is standalone_nodelet). The very last <node> creates a standalone node, basically loading in the nodelet as the only nodelet in this nodelet manager, therefore making the nodelet a normal node (see here line 311 for what happens exactly)
  2. I dont know, seems like a mistake to me, but maybe I am wrong.
  3. I think this is a mistake, there should be a comannd="load" there
  4. You should be able to see the nodelets running via rosnode list. If you listen to the topics remapped_output, Plus2/out and Plus3/out (before you start the nodelets) you should be able to see the result of the performed additions. See here for the implementation of this particular nodelet.

The image_proc package uses nodelets quite heavily, maybe it's useful for 'inspiration' (e. g. this launchfile).

edit flag offensive delete link more


Thanks! Is the Plus2/out the input Plust3/in like a pipe?

Oh and what is the purpose of a standalone nodelet (the last one in the example) if they are going to be like a normal node?

Oh and thanks for the image_proc example. I ll take a look!

Kansai gravatar image Kansai  ( 2020-07-25 20:32:28 -0600 )edit

I tried your suggestion 4 and I could see that it is working as expected. Thanks for the advice.

Now I wonder my questions 2 and 3... hummmm wonder why

I experimented with 2, Deleting one of the two rosparams and everything works fine. They seem redundant

Kansai gravatar image Kansai  ( 2020-07-25 22:30:20 -0600 )edit

You're welcome. It's not really a pipe. Plus2 publishes its results on the topic Plus2/out whenever it has a new one and Plus3 node subscribes to this topic for its input, but theoretically every node can listen to Plus2/out. In a more realistic scenario one node would publish an image from a camera on a topic like /camera and another node would subscribe to this topic, therefore receiving the published images from the first node. It would then process the images and publish the processed images on a new topic, where some higher level node can listen to and so on.

Julian98 gravatar image Julian98  ( 2020-07-26 00:10:43 -0600 )edit

Sometimes you only have a nodelet but want it to be a separate process (e. g. for running it with more resources/on another machine etc.). But having the nodelet instead of a node gives you more flexibility as you can decide, whether the nodelet should run in its own process (although it is best practice to also provide a node using the nodelet internally when you publish a node).

Julian98 gravatar image Julian98  ( 2020-07-26 00:17:13 -0600 )edit

If my answer is sufficient to answer your question, please consider marking the question as resolved.

Julian98 gravatar image Julian98  ( 2020-08-13 07:50:14 -0600 )edit

Question Tools



Asked: 2020-07-25 09:44:02 -0600

Seen: 765 times

Last updated: Jul 25 '20