-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Wait for goal result after cancelling BT action node (Galactic branch) #2436
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -275,6 +275,22 @@ class BtActionNode : public BT::ActionNodeBase | |
| } | ||
| } | ||
|
|
||
| auto start_time = node_->now(); | ||
| while (rclcpp::ok() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll counter this suggestion with moving this logic up a bit. We have the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I strongly agree with you, the while loop could be simplified. However:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My assertion (which you could test and let me know if I'm wrong) is that when the That still doesn't help you if the cancel_future failed, but that's not the issue we're addressing here and you're screwed either way 😄 |
||
| && !goal_result_available_ | ||
| && node_->now() - start_time < server_timeout_) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part of the condition I don't think you actually really care about the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is your
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mention
and point to the As far as I can tell from this PR there are 2 distinct issues you're trying to address (or just 1 and I'm misinterpreting for the second):
If only (B) is your issue, no changes are required to the code above this block and this block can be largely simplified without the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, that's right ...
... but no, not a cancel. This condition does not aim at getting the cancel result, but the goal result.
So I think that waiting for maximum two set of
since it strongly depends on the desired behavior of the sub-action when it is being cancelled, and since it seems normal to me to wait for the sub-action to properly ends before halting the BT.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In our use case, we set the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
From a behavior point of view, what we want more than anything else is the sub-action to be cleanly finished before halting the BT. To know if it is indeed cleanly finished, we check on the availability of the sub-action goal result, since the goal result is available only once the sub-action has ended. Once the sub-action goal result is available, the goal result callback is automatically executed. So yes, saying that what we want more than anything else is the sub-action to be cleanly finished, is actually saying we want to spin to get a result callback more than anything else.
No I don't agree with this, there is an explanation in this previous comment
Well, I would said only (B) is an issue, but not exactly. I would reformulate it this way to make it accurate (changes are in bold): So, I don't really agree with your conclusion about only (B) being an issue. If the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it -- see comment in the thread above. I think we're on the same page, but I think we can simplify this if we leverage some internal knowledge about how the actions work. If that turns out not to be true, then we can discuss what to do so we can make sure we process the goal callback. What you've suggested is not unreasonable though. |
||
| RCLCPP_DEBUG( | ||
| node_->get_logger(), | ||
| "Waiting for goal result after cancelling, for action %s", action_name_.c_str()); | ||
| callback_group_executor_.spin_some(); | ||
| rclcpp::sleep_for(std::chrono::milliseconds(1)); | ||
| } | ||
| if (!goal_result_available_) { | ||
| RCLCPP_ERROR_STREAM( | ||
| node_->get_logger(), | ||
| "Failed to get result for action " << action_name_.c_str() << " after cancelling. BT might not finish cleanly. "); | ||
| } | ||
|
|
||
| setStatus(BT::NodeStatus::IDLE); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.