-
Notifications
You must be signed in to change notification settings - Fork 418
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
[rclcpp_action] Action client holds weak pointers to goal handles #1122
Conversation
Fixes #861 It is against the design of ROS actions to rely on the status topic for the core implementation, instead it should just be used for introspection. Rather than relying on the status topic to remove references to goal handles, the action client instead holds weak pointers to the goal handles. This way as long as a user holds a reference to the goal handle they can use it to interact with the action client. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
I'll still have to update the examples that aren't already maintaining a reference to the goal handle. Otherwise, I expect them to break as pointed out in #861 (comment). |
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.
LGTM
So, it turns out this change didn't break our examples, because of a subtle way the lifetime of the goal handle is extended. If the user registers a result callback when sending the goal, then the shared_ptr is kept alive by the action client by passing it to this lambda: rclcpp/rclcpp_action/include/rclcpp_action/client.hpp Lines 633 to 636 in d06e8e0
I guess this is fine, though I think it's worth adding some documentation regarding the lifetime of the goal handle. |
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
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.
lgtm
…s2#1122) * [rclcpp_action] Action client holds weak pointers to goal handles Fixes ros2#861 It is against the design of ROS actions to rely on the status topic for the core implementation, instead it should just be used for introspection. Rather than relying on the status topic to remove references to goal handles, the action client instead holds weak pointers to the goal handles. This way as long as a user holds a reference to the goal handle they can use it to interact with the action client. Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Move cleanup logic to the end of the function Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Add TODO Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Log debug messages when dropping a weak references to goal handles Signed-off-by: Jacob Perron <jacob@openrobotics.org> * Improve documentation Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Fixes #861
It is against the design of ROS actions to rely on the status topic for the core implementation,
instead it should just be used for introspection.
Rather than relying on the status topic to remove references to goal handles, the action client
instead holds weak pointers to the goal handles. This way, as long as a user holds a reference to
the goal handle they can use it to interact with the action client.
Draft PR for now as I try to determine if this actually fixes the issue (hopefully with a reliable reproduction of the bug).For a reproduction, see #861 (comment)