Best practice/documentation of using which MessageType for topic callback

asked 2019-05-09 10:05:56 -0500

antibus gravatar image

updated 2019-05-13 08:54:10 -0500

Hi

I am looking for a documentation for "when to use which MessageType in a callback"? Especially for nodelets to avoid copying of messages.

Like

void callback(const MessageType & msg);
void callback(MessageTypePtr & msg);
void callback(MessageTypeConstPtr & msg);
....etc

So, I understand, that MessageType and MessageTypePtr are basically the same when more then one nodes are subscribing (both cases involve copying). From C++ perspective this is somewhat counterintuitive (why do we actually have the MessageTypePtr in the first place?). Until recently I assumed the first copies the message while the second avoids the copying. This I found out more or less by accident. But does there exist a documentation about this? Or how/where should I figure this out?

Also, now I fear there are more misconceptions I have when using ROS which are actually not true.

edit retag flag offensive close merge delete