-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Create subscriber on constructor #4859
base: main
Are you sure you want to change the base?
Create subscriber on constructor #4859
Conversation
229c5a1
to
a7475eb
Compare
nav2_behavior_tree/plugins/condition/is_battery_low_condition.cpp
Outdated
Show resolved
Hide resolved
Signed-off-by: Tatsuro Sakaguchi <tatsuro.sakaguchi@g.softbank.co.jp>
a7475eb
to
7eb4915
Compare
@Tacha-S, your PR has failed to build. Please check CI outputs and resolve issues. |
Signed-off-by: Tatsuro Sakaguchi <tatsuro.sakaguchi@g.softbank.co.jp>
7eb4915
to
c65bdfe
Compare
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 approve of these changes, but I think this should be made for all BT nodes so that this behavior is consistent across the board. Plus, I'm sure you'll use other BT nodes and want this done for them anyway, so may as well save yourself the headache and batch it out now :-)
Understood. I will check and fix the other BT nodes as well. |
@Tacha-S, your PR has failed to build. Please check CI outputs and resolve issues. |
Signed-off-by: Tatsuro Sakaguchi <tatsuro.sakaguchi@g.softbank.co.jp>
f9ed2dc
to
99c1359
Compare
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'm not entirely sure if this PR is done / needing review, can you let me know?
I'm not seeing that all the nodes updated have the initialize
implementation so we create on construction to resolve your issue and set properly if the port is updated like in IsBatteryLow
.
In the node with |
Got it, I'm sorry that I was not clear. The pattern that is battery low established was good; checking for changes and creating the updated subscription if/when the topic changed. For BT nodes that derive from the
The other updates you made to things like SmootherSelector, ProgressCheckerSelector, etc all also have their own input port topics that need to be checked not just on construction, but when running an initialization when ticking from So, what I was asking was to create that same pattern you made for isBatteryLow for all BT nodes with subscriptions/publishers with topic input ports:
Whereas initialize calls Does that make sense? |
Thank you for the explanation, I understand. Once the changes are complete, I’ll reopen and reply again. |
Correct! I went through the files and you did identify all of the files that would need to be updated, so you don't need to go through every file again. The ones that you touched in this PR are all of them :-) Thanks for the help! |
Signed-off-by: Tatsuro Sakaguchi <tatsuro.sakaguchi@g.softbank.co.jp>
d460fc7
to
12249d0
Compare
@Tacha-S, your PR has failed to build. Please check CI outputs and resolve issues. |
I have made the corrections as you pointed out. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
|
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.
Small changes and LGTM!
service_name_, | ||
rclcpp::SystemDefaultsQoS(), | ||
callback_group_); | ||
createROSInterfaces(); |
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.
Should be initialize()
instead? This wouldn't setup the loop rate and timeouts
@@ -29,19 +29,25 @@ IsBatteryLowCondition::IsBatteryLowCondition( | |||
is_voltage_(false), | |||
is_battery_low_(false) | |||
{ | |||
createROSInterfaces(); |
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.
Shouldn't we do initialize()
here because initialize gets the input ports
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.
In general, should we change them all from createROSInterfaces()
in the constructor to initalize()
so that if there are other non-ros-interface making initialization steps that might be important for the interface definitions, we perform them here too?
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 consistently calling initialize()
in the constructor is a good idea, and I agree with that approach.
However, limiting createROSInterfaces()
to only within initialize()
and not calling either createROSInterfaces()
or initialize()
from the constructor would not resolve the issue mentioned in the issue, where the behavior during the first execution becomes undefined. Therefore, I would like to avoid this.
Basic Info
Description of contribution in a few bullet points
Description of documentation updates required from your changes
Description of how this change was tested
Future work that may be required in bullet points
For Maintainers: