Skip to content

Use ConstSharedPtr in subscription callbacks - #44

Merged
ahcorde merged 1 commit into
mainfrom
christophebedard/use-const-shared-ptr-callbacks
Nov 27, 2026
Merged

ahcorde merged 1 commit into
mainfrom
christophebedard/use-const-shared-ptr-callbacks

Conversation

@christophebedard

Copy link
Copy Markdown
Member

Description

Subscription callbacks taking a std::shared_ptr to a non-const message have been deprecated since ros2/rclcpp#2975 (Lyrical), and rclcpp is removing them. These callbacks do not modify the message, so take a ConstSharedPtr, including in the README examples.

The qc tutorial subscriber reads the data through get_data_ptr(), which needed a non-const buffer, so add a const overload that returns a read-only pointer.

Is this user-facing behavior change?

Did you use Generative AI?

Claude Opus 5.5 to make this change.

Additional Information

Companion PR: ros2/rclcpp#3449, which removes these callback signatures.

Subscription callbacks taking a `std::shared_ptr` to a non-const
message have been deprecated since
ros2/rclcpp#2975 (Lyrical), and they are being
removed in Rolling by ros2/rclcpp#3449. These
callbacks do not modify the message, so take a `ConstSharedPtr`,
including in the README examples.

The qc tutorial subscriber reads the data through `get_data_ptr()`,
which needed a non-const buffer, so add a `const` overload that
returns a read-only pointer.

Signed-off-by: Christophe Bedard <[email protected]>
@ahcorde
ahcorde merged commit caedd2f into main Nov 27, 2026
0 of 2 checks passed
@ahcorde
ahcorde deleted the christophebedard/use-const-shared-ptr-callbacks branch November 27, 2026 09:25
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.

2 participants