No version for distro humble showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro jazzy showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro kilted showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro ardent showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro bouncy showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro crystal showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro eloquent showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro dashing showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro galactic showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro foxy showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro iron showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro lunar showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro jade showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro indigo showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro hydro showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro kinetic showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro melodic showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).
No version for distro noetic showing rolling. Known supported distros are highlighted in the buttons above.

Repository Summary

Checkout URI https://github.com/ros2/rosidl_buffer_backends.git
VCS Type git
VCS Version main
Last Updated 2026-05-07
Dev Status DEVELOPED
Released UNRELEASED
Contributing Help Wanted (-)
Good First Issues (-)
Pull Requests to Review (-)

Packages

README

rosidl_buffer_backends

CUDA buffer backend implementation for rosidl::Buffer, enabling zero-copy GPU memory sharing between ROS 2 publishers and subscribers, plus a PyTorch-side helper library that builds on the same buffer infrastructure.

Packages

  • cuda_buffer – Core CUDA buffer library (VMM-backed IPC memory pool, host endpoint manager, ReadHandle/WriteHandle with CUDA event sync).
  • cuda_buffer_backend – BufferBackend plugin for CUDA IPC transport.
  • cuda_buffer_backend_msgs – ROS 2 message definitions for CUDA buffer descriptors.
  • libtorch_vendor – Vendor package that downloads and installs the pre-built LibTorch C++ distribution.
  • tensor_msgs – DLPack-aligned ExperimentalTensor.msg definition.
  • torch_conversions – Header-only helper library that converts between tensor_msgs/ExperimentalTensor and at::Tensor and exposes DLPack import / export. Replaces the older torch_buffer_backend plugin approach with a plain message + bridge library that rides on top of whichever rosidl::Buffer backend is registered (CUDA when available, CPU otherwise).

Prerequisites

  • A ROS 2 Rolling development environment. See the upstream Building ROS 2 on Ubuntu guide for the canonical source-build flow, or use the pixi workflow shipped by the ros2/ros2 meta-repo.
  • CUDA Toolkit (>= 11.8) on the host.

Per-package build, test, and run details live in each package’s README:

API overview

CUDA buffer backend (cuda_buffer_backend)

#include "cuda_buffer/cuda_buffer_api.hpp"

// Publisher: allocate + write directly to the output buffer.
sensor_msgs::msg::Image msg;
msg.data = cuda_buffer_backend::allocate_buffer(byte_count);
{
  auto wh = cuda_buffer_backend::from_output_buffer(msg.data, stream);
  uint8_t * out = wh.get_ptr();
  my_kernel<<<...>>>(out, ...);
}  // wh destructor records the write event on `stream`
publisher->publish(msg);

// Subscriber: input/read handle (waits on publisher's write event).
auto rh = cuda_buffer_backend::from_input_buffer(msg->data, stream);
use_data<<<...>>>(rh.get_ptr(), ...);  // rh.get_ptr() returns const uint8_t *

// Auto-promotion: passing a non-CUDA buffer allocates a fresh CUDA buffer
// and (for inputs) copies H2D;
auto rh = cuda_buffer_backend::from_input_buffer(cpu_or_other_buf, stream);

Torch tensor API (torch_conversions)

#include "torch_conversions/torch_conversions.hpp"
#include "tensor_msgs/msg/experimental_tensor.hpp"

// Publisher: allocate a Tensor message (accelerated backend when available).
auto guard = torch_conversions::set_stream();
auto msg = torch_conversions::allocate_tensor_msg(
  /*shape=*/{1080, 1920, 3}, torch::kUInt8);

// Wrap as at::Tensor without copying and write into it.
at::Tensor t_out = torch_conversions::from_output_tensor_msg(*msg);
my_pipeline(t_out);
publisher->publish(std::move(msg));

// Subscriber: independent tensor by default.
auto guard = torch_conversions::set_stream();
at::Tensor t_in = torch_conversions::from_input_tensor_msg(*received_msg);

The message schema carries DLPack’s dtype / shape / stride / offset metadata, while device placement is derived from the underlying rosidl::Buffer backend. Any DLPack-compatible framework (PyTorch, TensorFlow, JAX, CuPy, ONNX Runtime, …) can interoperate over the wire by converting to / from its own DLPack representation.

License

Apache-2.0

CONTRIBUTING

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that license:

5. Submission of Contributions. Unless You explicitly state otherwise,
   any Contribution intentionally submitted for inclusion in the Work
   by You to the Licensor shall be under the terms and conditions of
   this License, without any additional terms or conditions.
   Notwithstanding the above, nothing herein shall supersede or modify
   the terms of any separate license agreement you may have executed
   with Licensor regarding such Contributions.

Contributors must sign-off each commit by adding a Signed-off-by: ... line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the Developer Certificate of Origin (DCO).

Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/).