Skip to content

Conversation

@mini-1235
Copy link

Description

  • Add static assert for removed subscription callback signatures

Fixes #2972

Is this user-facing behavior change?

Yes

Did you use Generative AI?

No

Additional Information

When working on this PR, I noticed that #1713 only deprecates MessageT. However, looking at the comment here:

// Deprecated signatures:
using SharedPtrCallback =
std::function<void (std::shared_ptr<SubscribedType>)>;
using SharedPtrROSMessageCallback =
std::function<void (std::shared_ptr<ROSMessageType>)>;
using SharedPtrWithInfoCallback =
std::function<void (std::shared_ptr<SubscribedType>, const rclcpp::MessageInfo &)>;
using SharedPtrWithInfoROSMessageCallback =
std::function<void (
std::shared_ptr<ROSMessageType>,
const rclcpp::MessageInfo &)>;
using SharedPtrSerializedMessageCallback =
std::function<void (std::shared_ptr<rclcpp::SerializedMessage>)>;
using SharedPtrSerializedMessageWithInfoCallback =
std::function<void (std::shared_ptr<rclcpp::SerializedMessage>, const rclcpp::MessageInfo &)>;

it looks like the type_adaptation/serialized message are not yet deprecated, how should we proceed?

In the meantime, I have also updated the tests for type_adaptation/serialized to use std::shared_ptr<const>

@mini-1235
Copy link
Author

mini-1235 commented Nov 9, 2025

I have pulled and built the ROS2 repos from https://raw.githubusercontent.com/ros2/ros2/rolling/ros2.repos (Please let me know if there are any other repos I should include)

Removing std::shared_ptr<MessageT> would have an impact on:

Removing/Deprecating std::shared_ptr<TypeAdapter/Serialize Message> would affect:

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

@mini-1235 thanks for fixing up all the related packages and repositories.

changing signatures are totally fine things to do including this PR, but i want to discuss with you on either we should enforcement or deprecation here for the next release.

@mini-1235
Copy link
Author

I am not sure how to deal with the deprecated tests here

void shared_ptr_ta_free_func(std::shared_ptr<MyEmpty>) {}
void shared_ptr_ta_w_info_free_func(
std::shared_ptr<MyEmpty>, const rclcpp::MessageInfo &)
{}
INSTANTIATE_TEST_SUITE_P(
SharedPtrCallbackTests,
DispatchTestsWithTA,
::testing::Values(
// lambda
InstanceContext<MyTA>{"lambda_ta", rclcpp::AnySubscriptionCallback<MyTA>().set(
[](std::shared_ptr<MyEmpty>) {})},
InstanceContext<MyTA>{"lambda_ta_with_info",
rclcpp::AnySubscriptionCallback<MyTA>().set(
[](std::shared_ptr<MyEmpty>, const rclcpp::MessageInfo &) {})},
InstanceContext<MyTA>{"lambda", rclcpp::AnySubscriptionCallback<MyTA>().set(
[](std::shared_ptr<test_msgs::msg::Empty>) {})},
InstanceContext<MyTA>{"lambda_with_info",
rclcpp::AnySubscriptionCallback<MyTA>().set(
[](std::shared_ptr<test_msgs::msg::Empty>, const rclcpp::MessageInfo &) {})},
// free function
InstanceContext<MyTA>{"free_function_ta", rclcpp::AnySubscriptionCallback<MyTA>().set(
shared_ptr_ta_free_func)},
InstanceContext<MyTA>{"free_function_ta_with_info",
rclcpp::AnySubscriptionCallback<MyTA>().set(
shared_ptr_ta_w_info_free_func)},
InstanceContext<MyTA>{"free_function", rclcpp::AnySubscriptionCallback<MyTA>().set(
shared_ptr_free_func)},
InstanceContext<MyTA>{"free_function_with_info",
rclcpp::AnySubscriptionCallback<MyTA>().set(
shared_ptr_w_info_free_func)},
// bind function
BindContext<MyTA, std::shared_ptr<MyEmpty>>("bind_method_ta"),
BindContext<MyTA, std::shared_ptr<MyEmpty>, const rclcpp::MessageInfo &>(
"bind_method_ta_with_info"),
BindContext<MyTA, std::shared_ptr<test_msgs::msg::Empty>>("bind_method"),
BindContext<MyTA, std::shared_ptr<test_msgs::msg::Empty>, const rclcpp::MessageInfo &>(
"bind_method_with_info")
),
format_parameter_with_ta
);

Should I add #define RCLCPP_AVOID_DEPRECATIONS_FOR_UNIT_TESTS 1 like the previous PR or any other better approach?

@mini-1235 mini-1235 changed the title Add static assert for removed subscription callback signatures Deprecate the shared_ptr<MessageT> subscription callback signatures Nov 27, 2025
@mjcarroll
Copy link
Member

Should I add #define RCLCPP_AVOID_DEPRECATIONS_FOR_UNIT_TESTS 1 like the previous PR or any other better approach?

Please do!

Then we can remove them in the next cycle with find/replace

@mini-1235
Copy link
Author

Should I add #define RCLCPP_AVOID_DEPRECATIONS_FOR_UNIT_TESTS 1 like the previous PR or any other better approach?

Please do!

Then we can remove them in the next cycle with find/replace

Added!

Signed-off-by: mini-1235 <[email protected]>
Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

lgtm with green CI.

@fujitatomoya
Copy link
Collaborator

Pulls: #2975
Gist: https://gist.githubusercontent.com/fujitatomoya/76e9ee5ac26e9d10c870d5850669c3aa/raw/6757efc08e3846630a7c8cd8a07f4905bcd864c1/ros2.repos
BUILD args: --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/17705

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

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.

Deprecated subscription callback signatures are still compiling

4 participants