-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not to hold callback group in subscription #1833
not to hold callback group in subscription #1833
Conversation
6a6d7c9
to
7f02ce6
Compare
Woudln't be a better approach to remove the callback group field from the I think that this makes it much clearer because:
|
Thank you for your response.
Yes, make it as other entities did. It's ideal. From my point of view, I just considered not breaking ABI because it affects so many other repositories. I'd like to hear others' opinions about your recommendation. After that, I'll update it. |
Ok, IMO we shouldn't be afraid to break API/ABI to have clean and consistent code. If you end up following my suggestion, you will have to update the documentation to mention this breaking changes. |
Yes, agreed. ABI, in particular, we don't guarantee between releases at all, and we always rebuild all downstream packages. If we are going to break API, we should discuss it a little further and also probably have a deprecation cycle, but we can do that as well. All of that is to say is that on Rolling, we should do what we need to make the code "best", and then worry about API/ABI more fully if we try to backport it to a released version. |
Thank you, got it. To separate the After re-consideration, I think to separate the What about saving the necessary variable in the subscription, what do you think? @wjwwood rclcpp/rclcpp/include/rclcpp/subscription.hpp Lines 396 to 401 in 0775e2f
to * It is important to save a copy of this so that the rmw payload which it
* may contain is kept alive for the duration of the subscription.
*/
- const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> options_;
+ std::shared_ptr<rclcpp::detail::RMWImplementationSpecificSubscriptionPayload>
+ rmw_implementation_payload_; Notice that |
This is a rather arbitrary consideration IMO. There isn't a clear distinction of what should go into that data-structure and what not. Anyhow, I'm ok with your proposal of only storing the rmw_payload rather than the full options. |
7c5df21
to
126eeee
Compare
@@ -173,6 +174,57 @@ template< | |||
typename SubscriptionT = rclcpp::Subscription<MessageT, AllocatorT>, | |||
typename MessageMemoryStrategyT = typename SubscriptionT::MessageMemoryStrategyType, | |||
typename NodeT> | |||
[[deprecated("use another overloaded method create_subscription instead")]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should mention that the purpose of the deprecation is to have a separate argument for the callback group
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the message in the deprecated can be either the reason or suggestion, what about adding the reason here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll follow your suggestion, what about
[[deprecated("use another overloaded method create_subscription instead")]] | |
[[deprecated( | |
"To Keep consistency with other cases(Client, Service, Timer, etc) not hold callback_group,\n" \ | |
"the callback_group in the SubscriptionOptionsBase will be removed in the future since the\n" \ | |
"SubscriptionOptions is held in the Subscription and then the callback_group is depend\n" \ | |
"on the lifetime of Subscription.\n" \ | |
"Use\n" \ | |
" template<\n" \ | |
" typename MessageT,\n" \ | |
" typename CallbackT,\n" \ | |
" typename AllocatorT = std::allocator<void>,\n" \ | |
" typename SubscriptionT = rclcpp::Subscription<MessageT, AllocatorT>,\n" \ | |
" typename MessageMemoryStrategyT = typename SubscriptionT::MessageMemoryStrategyType\n" \ | |
" typename NodeT>\n" \ | |
" typename std::shared_ptr<SubscriptionT>\n" \ | |
" create_subscription(\n" \ | |
" NodeT & node,\n" \ | |
" const std::string & topic_name,\n" \ | |
" const rclcpp::QoS & qos,\n" \ | |
" CallbackT && callback,\n" \ | |
" const SubscriptionOptionsWithAllocator<AllocatorT> & options =(\n" \ | |
" SubscriptionOptionsWithAllocator<AllocatorT>()\n" \ | |
" ),\n" \ | |
" rclcpp::CallbackGroup::SharedPtr group = nullptr,\n" \ | |
" typename MessageMemoryStrategyT::SharedPtr msg_mem_strat = (\n" \ | |
" MessageMemoryStrategyT::create_default()\n" \ | |
" )\n" \ | |
" );\n" \ | |
"instead" | |
)]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think suggestion would be okay enough, since reason can be found on git history and on this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I agree that the deprecation message should be more specific. While some one could figure out why this change is happening by looking at the git/github history, that's not reasonable for the average user.
On the other hand I think the suggestion above is a bit too verbose.
I would propose something like:
[[deprecated("use another overloaded method create_subscription instead")]] | |
[[deprecated( | |
"use the signature which has the callback group before the message memory strategy, i.e. " | |
"create_subscription(node, topic_name, qos, callback, options, callback_group, msg_mem_strat)" | |
)]] |
I believe this suggestion is still under the line limit, but check the linters if you take it more or less as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rclcpp/rclcpp/include/rclcpp/parameter_client.hpp
Lines 214 to 215 in ee20dd3
const rclcpp::SubscriptionOptionsWithAllocator<AllocatorT> & options = ( | |
rclcpp::SubscriptionOptionsWithAllocator<AllocatorT>() |
this also needs to be updated accordingly?
the same fix needs to be applied to rclcpp::PublisherOptionsBase
as follow-up? other entities have dedicated argument for rclcpp::CallbackGroup
, if i am not missed.
@@ -173,6 +174,57 @@ template< | |||
typename SubscriptionT = rclcpp::Subscription<MessageT, AllocatorT>, | |||
typename MessageMemoryStrategyT = typename SubscriptionT::MessageMemoryStrategyType, | |||
typename NodeT> | |||
[[deprecated("use another overloaded method create_subscription instead")]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think suggestion would be okay enough, since reason can be found on git history and on this issue.
note for myself, this must be tested with |
Thank you, @fujitatomoya. I'll update it.
Yes, I'll update it in the next PR if this one can be merged. |
948946e
to
52e9814
Compare
rerun CI from #1833 (comment) The downstream repositories have the deprecated warning message as we expected. Update: |
aligned with ros2/rclcpp#1833 Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
aligned with ros2/rclcpp#1833 Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
aligned with ros2/rclcpp#1833 Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
(downstream packages are in ros2 repository, so we should address them at the same time, i guess.) anyway, all done. New CI: |
A failure test case in the CI. Log as below,
I need to reproduce it and confirm if it was introduced by this PR. |
This problem isn't introduced by this PR. |
@fujitatomoya I can go take a look and merge them all in, but do you know why CI is failing in #1833 (comment) ? |
@clalancette test repo file is old, i will rebase the repo file and restart the CI against master branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I missed the reason why, but unless there is a reason for it, the new signatures added to support the old argument order need a deprecation warning in code.
@iuhilnehc-ynos besides @wjwwood previous comments, i think we need to rebase this. i will do the dependent packages accordingly. |
aligned with ros2/rclcpp#1833 Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
aligned with ros2/rclcpp#1833 Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
aligned with ros2/rclcpp#1833 Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
…ription Signed-off-by: Chen Lihui <lihui.chen@sony.com>
Signed-off-by: Chen Lihui <lihui.chen@sony.com>
Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com> Signed-off-by: Chen Lihui <lihui.chen@sony.com>
remove depreacted in the template function since it's not supported. (ignored by gcc and failure in clang++) Signed-off-by: Chen Lihui <lihui.chen@sony.com>
Signed-off-by: Chen Lihui <lihui.chen@sony.com>
Signed-off-by: Chen Lihui <lihui.chen@sony.com>
Signed-off-by: Chen Lihui <lihui.chen@sony.com>
Signed-off-by: Chen Lihui <lihui.chen@sony.com>
a9601ed
to
49e677d
Compare
retry CI based on #1833 (comment) |
The failed test can't be reproduced in my local env(ubuntu20, ubuntu22).
@ros-pull-request-builder retest this please |
there are 3 more repositories to address this deprecation. i will do that later. |
aligned with ros2/rclcpp#1833 Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
aligned with ros2/rclcpp#1833 Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
windows failure https://ci.ros2.org/job/ci_windows/17074/ is unrelated. I think this is ready to merge, the followings must go with this.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes lgtm, with a few exceptions that I commented on.
Also we need to document this. I've asked folks where it should be documented, we're in a bit of a strange state at the moment where we don't want to put it in humble, but we don't have an I-turtle release page yet so we cannot put it under the "changes since the last release" section there yet. I'll update when I have an idea where to put it.
Finally, after re-reviewing this and seeing the changes (that we realized were needed after properly adding the deprecation warnings) and after my comments here (ros2/realtime_support#115 (review)), I'm questioning if this is the right direction to take.
It's true that this makes subscriptions "more like" the other entities, but I think that's less to do with them being right and subscription being wrong and more to do with the fact that subscriptions were the first to get their own options structure due to the number and complexity of them.
So I think a better alternative might be to instead change the option classes to add (yet another) layer to them. That would allow for us to fix this problem without new signatures of create_subscription()
and without any deprecations (maybe). What I was imagining was a new base class for the subscription (and publisher) options which did not contain problematic options (from a lifespan perspective) and the subscription would hold on to that base class while the user would use the full derived class to set up the options.
Also, it occurs to me that really the callback group and msg mem strat are executor specific, which is related to a shift in class layout that needs to happen to make wait set based use of our entities more natural, so really we should have like ExecutableSubscriptionOptions
inherit from SubscriptionOptionsWithAllocator
inherit from SubscriptionOptionsBase
, with a user-friendly SubscriptionOptions
which is just an alias to the ExecutableSubscriptionOptions
.
Something like this sketch:
// everything except the allocator and the callback group/msg mem strat
class SubscriptionOptionsBase;
// all the normal subscription options and the allocator
template<typename AllocatorT>
class SubscriptionOptionsWithAllocator<AllocatorT>
: public SubscriptionOptionsBase;
// all the normal subscription options plus things needed
// to use a subscription with an executor
template<typename AllocatorT>
class ExecutableSubscriptionOptions<AllocatorT>
: public SubscriptionOptionsWithAllocator<AllocatorT>;
{
// user code
SubscriptionOptions so;
so.callback_group = custom_callback_group;
so.message_memory_strategy = custom_mms;
auto sub = node->create_subscription<...>("...", 10, my_callback, so);
// could also support, but maybe deprecate (would affect less users):
// node->create_subscription<...>("...", 10, my_callback, so, custom_mms);
SubscriptionOptionsBase after = sub->get_subscription_options();
}
I won't block this pr on this suggestion, but I do think it's the better way to solve the problem. As we add more options the awkwardness of passing nullptr's for unused settings will just get worse.
@@ -173,6 +174,57 @@ template< | |||
typename SubscriptionT = rclcpp::Subscription<MessageT, AllocatorT>, | |||
typename MessageMemoryStrategyT = typename SubscriptionT::MessageMemoryStrategyType, | |||
typename NodeT> | |||
[[deprecated("use another overloaded method create_subscription instead")]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I agree that the deprecation message should be more specific. While some one could figure out why this change is happening by looking at the git/github history, that's not reasonable for the average user.
On the other hand I think the suggestion above is a bit too verbose.
I would propose something like:
[[deprecated("use another overloaded method create_subscription instead")]] | |
[[deprecated( | |
"use the signature which has the callback group before the message memory strategy, i.e. " | |
"create_subscription(node, topic_name, qos, callback, options, callback_group, msg_mem_strat)" | |
)]] |
I believe this suggestion is still under the line limit, but check the linters if you take it more or less as-is.
@@ -53,6 +60,7 @@ struct SubscriptionOptionsBase | |||
RMW_UNIQUE_NETWORK_FLOW_ENDPOINTS_NOT_REQUIRED; | |||
|
|||
/// The callback group for this subscription. NULL to use the default callback group. | |||
[[deprecated("use create_subscription with a dedicated callback_group instead")]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly this deprecation notice could be better I think, maybe:
[[deprecated("use create_subscription with a dedicated callback_group instead")]] | |
[[deprecated("pass the callback group directly to the method creating the subscription")]] |
I avoided create_subscription
because it's not an exact symbol and it's not clear from the text (without context) if it is supposed to be a function or class or what. Since there is both a free-function and several iterations of the method on the Node class and the LifecycleNode class, it's better we just say it like I suggested, I think.
@@ -362,12 +356,13 @@ TEST_F(TestMemoryStrategy, get_group_by_subscription) { | |||
memory_strategy()->get_group_by_subscription(subscription, weak_groups_to_nodes)); | |||
} // callback_group goes out of scope | |||
EXPECT_EQ( | |||
callback_group, | |||
nullptr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem right to me, are we just "silencing" this test rather than fixing it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callback_group goes out of scope, I think it should get nullptr like service.
@wjwwood @fujitatomoya I'll create another PR if I can use an elegant method to fix this issue in the future. |
agree on this.
no problem. those are just adjustments to suppress the warnings. maybe we can come back on this issue with different approach. |
keep consistency with other cases to not hold callback group in subscription
#1832 (comment)
The above link can jump but not show the correct location. Copy comments
That sounds fine, but it doesn't seem to be needed in this PR (which seems to be a replacement of #1754).
I would rather see this done in another PR if it's not needed here.
NOTE:
the callback group for subscription is needed (kept) here,
rclcpp/rclcpp/include/rclcpp/create_subscription.hpp
Line 137 in 536df11
not in the subscription
rclcpp/rclcpp/include/rclcpp/subscription.hpp
Line 146 in 536df11