dmabuf_transport

dmabuf_transport is a package for zero-copy transport ROS message with Linux dma-buf file descriptor.

Overview

Dmabuf Transport provides a way to share data between different hardware accelerators and different ROS nodes with zero-copy.

It is built on ROS 2 Type Adaption. It allows us to define methods for serializing directly to the user requested type, and/or using that type in intra-process communication without ever converting it.

QuickStart

  1. Add dependency in package.xml

    <depend>dmabuf_transport</depend>
    
  2. Add dependency in CMakeLists.txt

    find_package(dmabuf_transport REQUIRED)
    
    ament_target_dependencies(${PROJECT_NAME}
      # ...
      dmabuf_transport
    )
    
  3. Zero-copy transport dmabuf_transport types

    #include "dmabuf_transport/type/image.hpp"
    // create message
    auto msg = std::make_unique<dmabuf_transport::type::Image>();
    msg->header = std_msgs::msg::Header();
    // save message data to dmabuf
    auto dmabuf = lib_mem_dmabuf::DmaBuffer::alloc(1024, "/dev/dma_heap/system");
    // ... set data
    msg->dmabuf = dmabuf;
    
    // publish message
    pub_->publish(std::move(msg));
    
  • Check test directory to find more details.

Supported Types

The following table lists current supported types:

Dmabuf Transport Type

ROS Interface

dmabuf_transport::type::Image

sensor_msgs::msg::Image

dmabuf_transport::type::PointCloud2

sensor_msgs::msg::PointCloud2