Ros2 pub, dds sub, use zero copy

I want to verify the communication between ROS2 pub and DDS sub (using the zero copy of the iceoryx component,data type is string). How should I write this example

I think such questions should instead go to Maybe you can create a question there if my answer below isn’t sufficient. But as we are already here.

If I understand correctly, you want to have a ROS 2 publisher on one side and a pure DDS subscriber on the other. And you want to do zero-copy via iceoryx.

For this setup, you would be using ROS 2 with the rmw_cyclonedds_cpp. See here for how to switch the rmw implementation if Cyclone DDS is not the default.

Then, ensure that you have the shared memory transport with iceoryx enabled in Cyclone DDS. See here for instructions on how to do this.

Then, you should ensure you have the same topic names on both sides. Best check the exact name that is used on the ROS side with ros2 topic list

Not that you have true zero-copy only when using the loaned_messages API and bounded messages that aren’t based on heap-allocating data types. Otherwise there will be a serialization in between (all described in the Cyclone docu)

ros2 communication with dds
osrf/ros2_raw_dds_example: A project showing how to connect a raw DDS program to a ROS 2 graph (

zero copy transport
ZhenshengLee/ros2_shm_msgs: ROS2 shm_msg based zero-copy for image and pointcloud. (

you could intergrate two of the feature.

Thank you for sharing. Perhaps I should just say the mistake I encountered. When I use cyclonedds, I send a string using the publisher_member_function of ROS2 and subscribe to rt/topic using pure dds. If SharedMemory is not enabled, I can communicate and receive string data normally. If SharedMemory is enabled, communication is normal, but I receive an empty string。

Do you have any better solutions for this?