ZhenshengLee / ros2_shm_msgs

ROS2 shm_msg based zero-copy for image and pointcloud.
114 stars 22 forks source link

零拷贝发送与接受是一个地址吗 #8

Closed mcudsm closed 2 years ago

mcudsm commented 2 years ago

为啥我测试着不是一个地址呢

ZhenshengLee commented 2 years ago

请提供完整的程序和测试步骤,供我复现。

ZhenshengLee commented 2 years ago

关于不可避免的拷贝,可以参考 https://github.com/ros-perception/image_common/issues/212

mcudsm commented 2 years ago

您这个包编译没通过,如下错误

Starting >>> shm_msgs --- stderr: shm_msgs
CMake Warning at /opt/ros/galactic/share/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake:235 (add_library): Cannot generate a safe runtime search path for target shm_msgs__rosidl_typesupport_fastrtps_c__pyext because files in some directories may conflict with libraries in implicit directories:

runtime library [libssl.so.1.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
  /home/daism/anaconda3/lib
runtime library [libcrypto.so.1.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
  /home/daism/anaconda3/lib

Some of these libraries may not be found correctly. Call Stack (most recent call first): /opt/ros/galactic/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include) /opt/ros/galactic/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions) CMakeLists.txt:127 (rosidl_generate_interfaces)

/usr/bin/ld: cannot find -lshm_msgs_open3d collect2: error: ld returned 1 exit status make[2]: [test/CMakeFiles/test_shm_msgs_open3d.dir/build.make:99: test/test_shm_msgs_open3d] Error 1 make[1]: [CMakeFiles/Makefile2:1270: test/CMakeFiles/test_shm_msgs_open3d.dir/all] Error 2 make[1]: Waiting for unfinished jobs.... /home/daism/test/ros2_shm_msgs/test/test_array_helper.cpp: In member function ‘virtual void shm_msgs_MemCpy_Test::TestBody()’: /home/daism/test/ros2_shm_msgs/test/test_array_helper.cpp:17:8: warning: variable ‘array_256’ set but not used [-Wunused-but-set-variable] 17 | auto array_256 = std::array<unsigned char, 256>{'r','g','b'}; | ^~~~~ In file included from /home/daism/test/ros2_shm_msgs/include/shm_msgs/point_cloud2_iterator_8k.hpp:322, from /home/daism/test/ros2_shm_msgs/test/test_pointcloud_iterator_8k.cpp:41: /home/daism/test/ros2_shm_msgs/include/shm_msgs/impl/point_cloud2_iterator_8k.hpp: In member function ‘void shm_msgs::PointCloud2Modifier8k::reserve(size_t)’: /home/daism/test/ros2_shm_msgs/include/shm_msgs/impl/point_cloud2_iterator_8k.hpp:132:51: warning: unused parameter ‘size’ [-Wunused-parameter] 132 | inline void PointCloud2Modifier8k::reserve(size_t size) | ~^~ make: [Makefile:141: all] Error 2

Failed <<< shm_msgs [28.4s, exited with code 2]

Summary: 0 packages finished [28.7s] 1 package failed: shm_msgs 1 package had stderr output: shm_msgs

mcudsm commented 2 years ago

所以我用了另一个测试包https://github.com/ApexAI/ros2_shm_demo iceoryx使用的是https://github.com/eclipse-iceoryx/iceoryx.git 测试环境ros2 galactic ubuntu20.04 x86 测试步骤: 现启动iceoryx中的roudi 然后export 开启dds零拷贝的配置xml文件 然后分别运行ros2_shm_demo包中的talker与listener 现象:发送话题的地址与接收话题的地址不一致,按我的理解,发送方申请一块共享内存,接收方从这个内存读取数据,那么发送与接收因该是对同一个地址操作吧。

ZhenshengLee commented 2 years ago

所以我用了另一个测试包https://github.com/ApexAI/ros2_shm_demo

这个麻烦到https://github.com/ApexAI/ros2_shm_demo 提交issue哦

ZhenshengLee commented 2 years ago

现象:发送话题的地址与接收话题的地址不一致,按我的理解,发送方申请一块共享内存,接收方从这个内存读取数据,那么发送与接收因该是对同一个地址操作吧。

在pub和sub的全流程中,如果出现了拷贝,那么地址就会不一致,这里的zero-copy指的是使用了dds的零拷贝机制。

加wechat: zhensheng_li 讨论。

ZhenshengLee commented 2 years ago

您这个包编译没通过,如下错误

@mcudsm 编译原因已经解决,更新代码再试一下,如果有问题再打开该issue.