Ask Your Question
0

Nodelets general confusion

asked 2019-11-18 06:40:58 -0600

ligazetom gravatar image

Hello,

I am trying to understand the whole nodelet concept, since there are bits here and there all over forums but I cannot find one whole info about it.

What I know so far:

Why use nodelets: zero-copy communication, no serialization of data, only thing sent is the pointer

A little bit harder to implement, but nothing hardcore.

What I believe:

Zero-copy communication works ONLY between nodelets, and they MUST be loaded inside of single node. Otherwise they work as regular nodes.

Nodelet manager is any node, which is responsible for loading the nodelets.

Why am I even asking:

I am working with Velodyne VLP-16 LIDAR. They have transform_nodelet, which publishes lidar data to PointCloud2 format. I would like to read that data inside of my NODE, but what I understood so far is, if I load transform_nodelet from my NODE and if I subscribe to "velodyne_points" topic (which transform_nodelet publishes to) from my NODE, I would not be using zero-copy message, because it is NODE, not nodelet. Is this true?

Then if I were to implement my NODE as nodelet and if I wanted to publish my processed data to another topic, there is one other thing I don't understand. I've read, that if the whole nodelet concept should work, the callbacks have to have constPtr& as argument and the publisher should not change the data he just sent. So what I am confused about is, how to actually create messages and send them from nodelets. Should I always do something like:

CustomMes *message = new CustomMes();
message->mem = 5; //for example
publisher.publish(*message);

So if I will be creating another message, I won't be overwriting over the one already sent. Do I understand this correctly?

Also, what is the point of having handle to node_manager, and private nodelet_node_handle? Does it matter from which handle do I subscribe, or publish?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2019-11-18 11:26:36 -0600

Your "What I know so far" and "What I believe" sections are correct.

You'd have to load the nodelet into the same process as the node using the nodelet manager (conceptually you could load a nodelet into a node, but I'm not sure if you get all the zero-copy stuff. I think that happens in the manager level, but don't quote me on that. You'll have to read some source code).

You don't have to change anything about a sub/pub for a nodelet as long as you're taking in the pointers in the callback signature. Pubs/subs in a single process will automatically just get sent over. Subscribers or publishers outside the process will be serialized and sent over. Implementing all the Nodes in this chain as a Nodelet and loading them all with a nodelet manager is best practice.

If you have a chain where you have input of a PointCloud and output of some modified PointCloud (filtering, etc) then you'd have a topic in, PointCloudIn, and a topic out PointCloudOut and in the Cb of PointCloudIn you publish PointCloudOut.

edit flag offensive delete link more

Comments

I'm not sure you understood what I asked about sending from nodelet. Let's say I send message from nodelet1 to nodelet2 under the same nodelet manager. So I know, only pointer will be sent. Let's say I do it like this:

CustomMsg message;
message.variable = 5.;
publisher.publish(message);

Now the pointer is sent to nodelet2, he does some operation with it, but at the same time, nodelet1 can start preparing another message and while doing so he will be overwriting over the one he already sent, since nodelet1 sent only pointer to the data, not even saying, that if I were to send pointer to message which is local variable to some scope inside of nodelet1. So I have to be thinking about that data all the time right? So I have to make sure the data I sent pointer to to nodelet2 still exists, or ...(more)

ligazetom gravatar imageligazetom ( 2019-11-19 01:56:22 -0600 )edit
1
gvdhoorn gravatar imagegvdhoorn ( 2019-11-19 02:37:34 -0600 )edit

Oh yes. You are correct. Thank you!

ligazetom gravatar imageligazetom ( 2019-11-19 03:26:30 -0600 )edit
2

answered 2019-11-18 17:12:04 -0600

Note that if you run a rosnode info on your nodelet manager. i.e.

rosnode info /camera_nodelet_manager

you can see if zero-copy is used by looking at the connection output:

 * topic: /camera/image_raw
    * to: /camera_nodelet_manager (http://robot:44207/)
    * direction: inbound
    * transport: INTRAPROCESS

INTRAPROCESS means zero-copy transport is used, TCPROS means standard transport with serialization. Most useful to use when the launch setup isn't extremely complex, as otherwise there might be mix of connection types.

edit flag offensive delete link more

Comments

Great! Very useful, thanks.

ligazetom gravatar imageligazetom ( 2019-11-20 02:16:08 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-11-18 06:37:52 -0600

Seen: 36 times

Last updated: Nov 18