Skip to content

Commit

Permalink
README: Move content to QRB ROS document
Browse files Browse the repository at this point in the history
Signed-off-by: Peng Wang <[email protected]>
  • Loading branch information
penww committed Jan 6, 2025
1 parent 8917873 commit 2d625a1
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 238 deletions.
62 changes: 0 additions & 62 deletions .clang-format

This file was deleted.

40 changes: 0 additions & 40 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

Empty file removed .github/PULL_REQUEST_TEMPLATE.yml
Empty file.
37 changes: 0 additions & 37 deletions .github/workflows/basic-build.yml

This file was deleted.

113 changes: 15 additions & 98 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,118 +4,35 @@ dmabuf_transport is a package for zero-copy transport ROS message with Linux dma

## Overview

[Dmabuf Transport](https://github.com/quic-qrb-ros/dmabuf_transport) provides a way to share data between different hardware accelerators and different ROS nodes with zero-copy.
[Dmabuf Transport](https://github.com/quic-qrb-ros/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](https://ros.org/reps/rep-2007.html). 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.

We can define our adapted types with Linux dma-buf, and send dma-buf descriptor with ROS. Then use [ROS Composition](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Composition.html) to confirm ROS nodes running in a single process, it enables zero-copy over the pipeline.

## System Requirements
> This package need Linux kernel 5.12+ and ROS Humble later version.
- Linux kernel version 5.12 and later, for kernel dma-buf support.
- ROS 2 Humble and later, for type adaption support.
## Documentation

## QuickStart
Please refer to the [Dmabuf Transport](https://quic-qrb-ros.github.io/main/packages/qrb_ros_transport/dmabuf_transport.html) for more documents.
- [Overview](https://quic-qrb-ros.github.io/main/packages/qrb_ros_transport/dmabuf_transport.html#overview)
- [Quickstart](https://quic-qrb-ros.github.io/main/packages/qrb_ros_transport/dmabuf_transport.html#quickstart)
- [Updates](https://quic-qrb-ros.github.io/main/packages/qrb_ros_transport/dmabuf_transport.html#updates)

## Code Sync and Build
## Contributing

Currently, we only support build with QCLINUX SDK.
We would love to have you as a part of the QRB ROS community. Whether you are helping us fix bugs, proposing new features, improving our documentation, or spreading the word, please refer to our [contribution guidelines](./CONTRIBUTING.md) and [code of conduct](./CODE_OF_CONDUCT.md).

1. Setup QCLINUX SDK environments follow this document: [Set up the cross-compile environment](https://docs.qualcomm.com/bundle/publicresource/topics/80-65220-2/develop-your-first-application_6.html?product=1601111740013072&facet=Qualcomm%20Intelligent%20Robotics%20(QIRP)%20Product%20SDK&state=releasecandidate)
- Bug report: If you see an error message or encounter failures, please create a [bug report](../../issues)
- Feature Request: If you have an idea or if there is a capability that is missing and would make development easier and more robust, please submit a [feature request](../../issues)

2. Create `ros_ws` directory in `<qirp_decompressed_workspace>/qirp-sdk/`
## Authors

```bash
mkdir -p <qirp_decompressed_workspace>/qirp-sdk/ros_ws
```
* **Peng Wang** - *Initial work* - [penww](https://github.com/penww)

3. Clone this repository and dependencies under `<qirp_decompressed_workspace>/qirp-sdk/ros_ws`
See also the list of [contributors](https://github.com/quic-qrb-ros/dmabuf_transport/graphs/contributors) who participated in this project.

```bash
cd <qirp_decompressed_workspace>/qirp-sdk/ros_ws
git clone https://github.com/quic-qrb-ros/lib_mem_dmabuf.git
git clone https://github.com/quic-qrb-ros/dmabuf_transport.git
```

4. Build projects

```bash
export AMENT_PREFIX_PATH="${OECORE_TARGET_SYSROOT}/usr;${OECORE_NATIVE_SYSROOT}/usr"
export PYTHONPATH=${PYTHONPATH}:${OECORE_TARGET_SYSROOT}/usr/lib/python3.10/site-packages
colcon build --merge-install --cmake-args \
-DPython3_ROOT_DIR=${OECORE_TARGET_SYSROOT}/usr \
-DPython3_NumPy_INCLUDE_DIR=${OECORE_TARGET_SYSROOT}/usr/lib/python3.10/site-packages/numpy/core/include \
-DPYTHON_SOABI=cpython-310-aarch64-linux-gnu -DCMAKE_STAGING_PREFIX=$(pwd)/install \
-DCMAKE_PREFIX_PATH=$(pwd)/install/share \
-DBUILD_TESTING=OFF
```
## Using dmabuf_transport in your project

1. Add dependency in package.xml

```xml
<depend>dmabuf_transport</depend>
```

2. Add dependency in CMakeLists.txt

```cmake
find_package(dmabuf_transport REQUIRED)
ament_target_dependencies(${PROJECT_NAME}
# ...
dmabuf_transport
)
```

3. Zero-copy transport dmabuf_transport types

```c++
#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](./test/) directory to find more details.

## Supported Types

The following table lists current supported types:

| Zero Copy Transport Type | ROS Interface |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| [dmabuf_transport::type::Image](./include/dmabuf_transport/type/image.hpp) | [sensor_msgs::msg::Image](https://github.com/ros2/common_interfaces/blob/rolling/sensor_msgs/msg/Image.msg) |
| [dmabuf_transport::type::PointCloud2](./include/dmabuf_transport/type/pointcloud2.hpp) | [sensor_msgs::msg::Imu](https://github.com/ros2/common_interfaces/blob/rolling/sensor_msgs/msg/PointCloud2.msg) |

## Supported Platforms

This package is designed and tested to be compatible with ROS 2 Humble running on Qualcom RB3 gen2.

| Hardware | Software |
| ------------------------------------------------------------ | ----------------- |
| [Qualcomm RB3 gen2](https://www.qualcomm.com/developer/hardware/rb3-gen-2-development-kit) | LE.QCROBOTICS.1.0 |

## Resources

- [ROS 2 Type Adaption](https://ros.org/reps/rep-2007.html): ROS 2 new feature to implement zero copy transport.
- [Linux dma-buf](https://docs.kernel.org/driver-api/dma-buf.html): Linux kernel subsystem for sharing buffers for hardware (DMA) access across multiple device drivers and subsystems, and for synchronizing asynchronous hardware access
- [lib_mem_dmabuf](https://github.com/quic-qrb-ros/lib_mem_dmabuf): Library for access and interact with Linux DMA heaps.

## Contributions

Thanks for your interest in contributing to dmabuf_transport! Please read our [Contributions Page](CONTRIBUTING.md) for more information on contributing features or bug fixes. We look forward to your participation!

## License

dmabuf_transport is licensed under the BSD 3-clause "New" or "Revised" License.

Check out the [LICENSE](LICENSE) for more details.
Project is licensed under the [BSD-3-clause License](https://spdx.org/licenses/BSD-3-Clause.html). See [LICENSE](./LICENSE) for the full license text.
1 change: 0 additions & 1 deletion include/dmabuf_transport/type/image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ struct rclcpp::TypeAdapter<dmabuf_transport::type::Image, sensor_msgs::msg::Imag
destination.is_bigendian = source.is_bigendian;
destination.step = source.step;


if (source.dmabuf == nullptr || source.dmabuf->fd() <= 0) {
RCLCPP_ERROR(rclcpp::get_logger("dmabuf_transport"), "image: dmabuf is null");
return;
Expand Down

0 comments on commit 2d625a1

Please sign in to comment.