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.
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
Add ParameterEventsSubscriber class #829
Add ParameterEventsSubscriber class #829
Changes from 20 commits
6473041
3246e34
cdf4156
72817ab
884a2d8
f189327
a010d2d
f67d829
12329bf
921d2b4
7c19dbb
9cc41c7
2559434
0d5d75c
e4bc1d8
f360350
36e0190
e41f75c
b3b683f
8fb32de
60533db
ab4ff32
894da98
3404ec9
d4128de
1201f4f
18e72cf
e08612c
a4f5533
cbc8989
f011c3d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 class needs documentation on how to use it. Perhaps also a new example to show how it is used.
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 agree, I was planning to provide additional documentation at some point. Would an example go in https://github.com/ros2/demos/tree/master/demo_nodes_cpp/src/parameters ?
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 this comment still applies, you could either have a small example in the doc block here, or you could add an example to either the
demo_nodes_cpp
package or this repository:https://github.com/ros2/examples/tree/master/rclcpp
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 it would be more clear in either
examples
ordemo_nodes_cpp
. I can make a separate PR in one of those repos after this one?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.
Even if you put something in
examples
ordemo_nodes_cpp
this class needs documentation.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.
@mjeronimo this comment still applies I think.
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.
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.
It's kind of odd that
add_parameter_event_callback()
returns a shared pointer but this takes a raw pointer.I think this should either take a shared pointer (maybe as a const reference), or maybe a const reference to the handle. Is the address of the handle important or are the contents sufficient?
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 believe @bpwilcox was following suit with a similar usage in the rclcpp::Node class:
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 that the original method in rclcpp::Node used that signature because:
We're using a raw pointer to identify the handle, so we only need a raw pointer to remove it from the map.
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.
But it's not documented that letting the shared pointer returned by
add_parameter_event_callback
go out of scope will automatically remove it, unlike the inspiration for these signatures,Node::add_on_set_parameters_callback()
. As far as I can tell from the code, it is not the case that letting this shared pointer go out of scope will result in the callback getting removed. So I don't see any reason for it to be returned as a shared_ptr.So going back to my original thing, I think the add function should return a raw pointer (as there's no need to have shared ownership) or the remove function should take a shared pointer so it is symmetric with the add function.
Since automatic removal is not happening, it sounds like it should never be a shared pointer in the first place.
And since the handle is trivially copied, maybe it should just return a
OnSetParametersCallbackHandle
from add and take aconst OnSetParametersCallbackHandle &
in remove?I still just don't see why we're returning a shared ptr from add but taking a raw pointer 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.
That sounds good to me.
I think that the inconsistency with the "parameters acceptation callbacks" is a bit undesired, but it sounds ok.
i.e.: I would either always have scoped handles or unscoped ones.