ros2 / rmw_iceoryx

rmw implementation for iceoryx
Apache License 2.0
144 stars 27 forks source link

Question: will rmw_iceoryx reduce the time of publish()? #95

Closed felixf4xu closed 9 months ago

felixf4xu commented 10 months ago

Hi,

I'm currently using RMW_IMPLEMENTATION=rmw_cyclonedds_cpp and in my code below

  sensor_msgs::msg::PointCloud2 map_msg;
  pcl::toROSMsg(*map_pcl, map_msg);
  ndt_map_pub->publish(map_msg); //ros2 topic bw /ndt_map: 125.35MB

the function of publish costs about 139,394 us, which is unacceptably slow.

I'd like to check if I switch to rmw_iceoryx, because of the zero-copy design, will the function of publish cost less time?

mossmaurice commented 10 months ago

@felixf4xu Thanks, for raising this question!

In order for messages to be zero-copyable they need to have a fixed-sized otherwise iceoryx does not know how much memory to allocate in the shared memory area.

the function of publish costs about 139,394 us, which is unacceptably slow.

What you are seeing here is the simple, straightforward serialization implemented in rmw_iceoryx. It takes some time because the publisher needs to serialize the message and the subscriber needs to deserialize.

To make full use of zero-copy, what you would need to do in your project, is to change all messages to be fixed-size. For example, have a look at this repository. Here you can see different point cloud message types defined. The caveat with such an approach is that the compatibility between the message types breaks and you need some conversion method.

mossmaurice commented 9 months ago

@felixf4xu Closing this issue. If you have more questions, feel free to re-open this issue.