Add acceptable_buffer_backends field in SubscriptionOptionsBase#3098
Open
Add acceptable_buffer_backends field in SubscriptionOptionsBase#3098
Conversation
Signed-off-by: CY Chen <cyc@nvidia.com>
hidmic
reviewed
Mar 18, 2026
Comment on lines
+157
to
+160
| if (!acceptable_buffer_backends.empty()) { | ||
| result.rmw_subscription_options.acceptable_buffer_backends = | ||
| acceptable_buffer_backends.c_str(); | ||
| } |
Contributor
There was a problem hiding this comment.
@nvcyc hmm, this implicitly ties the lifetimes of both rclcpp and rcl options. If the rclcpp object is destroyed before the rcl struct is used, we'll get a SEGFAULT. Note how content filtering options are allocated and managed by rcl.
Member
There was a problem hiding this comment.
Agree, I think that we need to allocate a new string and copy over here. Look at rcl_subscription_options_set_content_filter_options for a reference.
|
|
||
| template<typename AllocatorT> | ||
| static rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> | ||
| force_cpu_buffer_backend_( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request adds the
acceptable_buffer_backendssubscription 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):SubscriptionOptionsBaseaddsacceptable_buffer_backends(std::string, default"cpu").to_rcl_subscription_options()copies it intormw_subscription_options.acceptable_buffer_backendswhen non-empty.generic_subscription.hpp): Constructor forcesacceptable_buffer_backendsto"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 passacceptable_buffer_backendswill 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.