Robotics StackExchange | Archived questions

Is the .msg in memory format the same for ROS1 and ROS2?

If I defined some some type FOO, with members X and Y, will the in memory structure generated from .msg "rosidl" be the same as the the in memory structure generated from the rosidl_dds generated .idl? That is, if I do pointer math like (void) myfoo.X - (void) myfoo.Y will I get the same answer in ROS1 and ROS2?

I understand that there are wire format differences, but does the DDS version basically wrap the ROS1 version, such that if I get a pointer to my FOO, I can pass it to the same function regardless of which transport we use?

Realize this is pretty basic, so appreciate the help and patience!

Asked by alcoholiday on 2018-05-04 13:42:41 UTC

Comments

I don't understand what (void) myfoo.X - (void) myfoo.Y should do, are you calculating an offset into the message structure?

Asked by William on 2018-05-04 15:57:39 UTC

It was just my lame way of saying that the byte layout of the structure was the same. It may not have been a helpful clarification. :)

Asked by alcoholiday on 2018-05-04 19:32:32 UTC

Ok, that's fine. I don't think the byte layout will be the same, since some of the types have changed (byte is now unsigned, and time and duration are now messages, not built-in types). You can compare the ROS 1 with the ROS 2: http://design.ros2.org/articles/interface_definition.html

Asked by William on 2018-05-04 19:35:17 UTC

It looks like the primitive types like byte/char/uint8/uint16, etc are all the same, so maybe as long as the messages are expressed using the those primitives, the structures would be the same.

But if the "time" type has a different layout in ros2, then I would not expect those to be compatible.

Asked by alcoholiday on 2018-05-04 20:04:46 UTC

Answers

No the in memory layouts are not exactly the same. They are similar and have similar APIs for easier porting, but they are not intended to be compatible.

Asked by tfoote on 2018-05-04 15:47:49 UTC

Comments

Thanks. I thought I read that when using FastRTPS that the DDS .idl is ignored. So maybe my question should be, is this ALSO the case when using the default middleware on top of FastRTPS?

Asked by alcoholiday on 2018-05-04 19:34:04 UTC