A ROS2 community prototype allows recording of CUDA-backed rosidl::Buffer topics by enabling the recorder to handle serialization on a separate thread, reducing publish latency from approximately 4.6 ms to 0.14 ms for 1920x1080 images at 30 Hz on an RTX 3060. The tool introduces opt-in command-line flags --acceptable-buffer-backends and --buffer-aware-topics, with the bag format remaining unchanged. Only the CUDA backend has been tested on hardware, and manual topic listing is required since the recorder cannot automatically detect publisher backends.
On this page
Hi all,
With rosidl::Buffer backends arriving in Lyrical, the recorder faces an issue: ros2 bag record only accepts the cpu backend, so every publisher converts its buffers to CPU memory and serializes them inside publish(), just because a recorder is subscribed. This prototype lets the recorder accept a backend and does that work on its own thread instead.
What it does
Two opt-in options, --acceptable-buffer-backends (default cpu, so nothing changes) and --buffer-aware-topics, also available as node parameters and in rosbag2_py.
A subscription that takes messages through the typed path and serializes them on the recorder’s side. A generic subscription cannot do this, because rmw_fastrtps deliberately rejects serialized takes of backend messages. The bag format and stored bytes are the same as before.
An unknown backend name fails at startup and lists the installed backends.
A message whose backend buffer arrives empty is dropped, counted as lost and logged, instead of being written as a valid-looking empty message.
Numbers
CUDA publisher, 1920x1080 sensor_msgs/Image at 30 Hz, RTX 3060: publish() goes from about 4.6 to 6 ms to 0.14 ms. The recorded messages are identical to the CPU path.
ros2 bag record -s mcap -o my_bag --acceptable-buffer-backends any --topics /my_cuda_image
Caveats
The recorder cannot see which backend a publisher uses (no public rmw/rclcpp API for it), so --buffer-aware-topics is a manual list. Types without a rosidl::Buffer field automatically keep the cheaper generic subscription.
Conversion runs on one executor thread, so a recorder with several 4K streams at 30 Hz can fall behind. A worker pool is a follow-up.
Only the CUDA backend has been tested on hardware.
I’d love to hear back from the community if it’s useful and if there’s any bugs I might have overlooked.
Timezone · UTC
Article dates follow your selected timezone. Briefing editions use Hong Kong time (UTC+8).