Skip to content

Add acceptable_buffer_backends field in SubscriptionOptionsBase#3098

Open
nvcyc wants to merge 3 commits intorollingfrom
native_buffer/8-rclcpp
Open

Add acceptable_buffer_backends field in SubscriptionOptionsBase#3098
nvcyc wants to merge 3 commits intorollingfrom
native_buffer/8-rclcpp

Conversation

@nvcyc
Copy link
Copy Markdown

@nvcyc nvcyc commented Mar 16, 2026

Description

This pull request adds the acceptable_buffer_backends subscription option in rclcpp, which corresponds to the subscription field with the same name introduced in rmw in ros2/rmw#416. This option allows subscribers to control which buffer backends they accept, with a backward-compatible default of CPU-only.

This pull request consists of the following key changes:

  • rclcpp (subscription_options.hpp): SubscriptionOptionsBase adds acceptable_buffer_backends (std::string, default "cpu"). to_rcl_subscription_options() copies it into rmw_subscription_options.acceptable_buffer_backends when non-empty.
  • Generic subscription (generic_subscription.hpp): Constructor forces acceptable_buffer_backends to "cpu" ensuring serialized messages received by generic subscriptions are always CPU-based, which will be used by ros2 bag record for direct storage in bag files.

Is this user-facing behavior change?

The default value "cpu" preserves existing behavior -- subscriptions only accept CPU-backed data unless explicitly opting in. This is a new API surface but is additive and backward-compatible. Existing code that does not pass acceptable_buffer_backends will behave identically to before.

Did you use Generative AI?

No.

Additional Information

This PR is part of the broader ROS 2 native buffer feature introduced in this post.
It depends on the subscription field with the same name introduced in rmw in ros2/rmw#416.

Copy link
Copy Markdown
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass

Copy link
Copy Markdown
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nvcyc nvcyc force-pushed the native_buffer/8-rclcpp branch from 29e1cee to 67f9def Compare March 31, 2026 06:34
@nvcyc
Copy link
Copy Markdown
Author

nvcyc commented Mar 31, 2026

Since all subscription is set to only accept "cpu"-based messages by default, the forced opts.acceptable_buffer_backends = "cpu"; setting in the generic subscription is becoming redundant, and hence removed with the commit 67f9def

@nvcyc
Copy link
Copy Markdown
Author

nvcyc commented Mar 31, 2026

Pulls: #3098
Gist: https://gist.githubusercontent.com/nvcyc/8016e85eb31d063db11f8e4596250258/raw/14dc7eafd4837dd461d8e8c891538169d60b06f0/ros2.repos
BUILD args: --continue-on-error --packages-above-and-dependencies rclcpp
TEST args: --packages-above rclcpp
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/18752

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

nvcyc added 3 commits April 1, 2026 00:18
Signed-off-by: CY Chen <cyc@nvidia.com>
@nvcyc nvcyc force-pushed the native_buffer/8-rclcpp branch from 67f9def to 34a0ac2 Compare April 1, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants