-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add Pause and SequenceWithBlackboardMemory BT nodes #5247
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
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.
So this is missing tests coverage - but you know that :-) Also make sure to fix DCO
@@ -0,0 +1,98 @@ | |||
// Copyright (c) 2019 Intel Corporation |
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 all of these should be updated :-)
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.
@redvinaa I meant updated with your company since you wrote these :-)
nav2_behavior_tree/include/nav2_behavior_tree/plugins/control/pause.hpp
Outdated
Show resolved
Hide resolved
nav2_behavior_tree/include/nav2_behavior_tree/plugins/control/pause.hpp
Outdated
Show resolved
Hide resolved
@@ -390,6 +390,15 @@ | |||
|
|||
<Control ID="RoundRobin"/> | |||
|
|||
<Control ID="Pause"> |
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.
Note: Add to the docs.nav2.org for new pages for these 2 nodes + migration guide update for the nodes and how to use them for pause / resume navigation behavior within the BT
nav2_behavior_tree/plugins/control/sequence_with_blackboard_memory.cpp
Outdated
Show resolved
Hide resolved
BT::NodeStatus Pause::tick() | ||
{ | ||
unsigned int children_count = children_nodes_.size(); | ||
if (children_count < 1 || children_count > 4) { |
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.
Docs on the < 1 || > 4
is important. I'd add it both in the header doxygen, the BT walkthrough or tutorial, and the configuration guide page.
@redvinaa, your PR has failed to build. Please check CI outputs and resolve issues. |
Woah, this suddenly became more serious than I expected :D |
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.
Woah, this suddenly became more serious than I expected :D
I think this is really great work! Definitely happy to have it contributed! 🥇
I still have to write the tests and make this work with my jazzy stack, so it might take some time.
OK! Only really nitpicks, tests, and doc updates left in my book
|
||
void switchState(const state_t new_state); | ||
|
||
rclcpp::Node::SharedPtr node_; |
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.
Store the logger not the node please
} | ||
|
||
if (state_ != PAUSED) { | ||
RCLCPP_INFO(node_->get_logger(), "PAUSE_REQUESTED"); |
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 log can be a little more than this 😉
} | ||
|
||
if (state_ == PAUSED) { | ||
RCLCPP_INFO(node_->get_logger(), "RESUME_REQUESTED"); |
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 log can be a little more than this 😉
* - resume_service_name: name of the service to resume | ||
* | ||
* Usage: | ||
* <Pause pause_service_name="/pause" resume_service_name="/resume"> |
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.
Can we work a little on the naming here: Unpaused --> Active? Resume? Processing?
Unpaused gave me a bit of back and forth to understand & the ON_RESUME
branch is using the word "resume" on "unpaused".
Also, Pause
should now be PauseResumeController
BT::NodeStatus PauseResumeController::tickChildAndTransition() | ||
{ | ||
// Return RUNNING and do nothing if specific child is not used | ||
const uint child_idx = child_indices.at(state_); |
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.
Type out (here and anywhere else) unsigned int
. This helps with windows compatibility
BT::NodeStatus PauseResumeController::tickChildAndTransition() | ||
{ | ||
// Return RUNNING and do nothing if specific child is not used | ||
const uint child_idx = child_indices.at(state_); |
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.
Can we do this logic in the switchState
function? Switch to the correct state if not implemented so that when tickChildAndTransition
is called we do useful work.
@redvinaa, your PR has failed to build. Please check CI outputs and resolve issues. |
1 similar comment
@redvinaa, your PR has failed to build. Please check CI outputs and resolve issues. |
@SteveMacenski I started writing the tests and I have a few questions. The dummy BT node used for tests now returns Also, could you give me some pointers on how to write tests for the |
I found the bug which didn't let me set |
Sorry for the delay - I've been underwater the last couple of weeks and now committing today to get through my email review backlog. I apologize for the delay and thank you for your help! For tests, you can do something more in the theme of the action nodes: https://github.com/ros-navigation/navigation2/blob/main/nav2_behavior_tree/test/plugins/action/test_append_goal_pose_to_goals_action.cpp. Here, we make an example BT XML that is loaded and used instead. This is actually a better way to write the tests IMO and the dummy node manual tree population done in the control test you linked to is an outdated way. We know those can have some problems since the tree isn't being constructed in the same way it would be in an application. You could still potentially use a dummy node within the tree, but the tree itself is constructed fully, including the ports and blackboard. That way, the blackboard of the BT is maintained between ticks since it acts like a proper behavior tree (because it is one). I think that answers your question! |
@redvinaa, your PR has failed to build. Please check CI outputs and resolve issues. |
I've implemented the tests using xml strings as in the action nodes, and DummyNodes. I've had to be creative, because none of the existing tests needed this level of complexity. Tell me what you think of this solution @SteveMacenski. I've added a new header file to access nodes from the tree and cast them to the correct type. I also had to modify the DummyNode implementation a bit, so it returns IDLE after resetting, but on tick it again returns the state that it was set to. I don't think it breaks existing tests. |
@redvinaa, your PR has failed to build. Please check CI outputs and resolve issues. |
@redvinaa, your PR has failed to build. Please check CI outputs and resolve issues. |
1 similar comment
@redvinaa, your PR has failed to build. Please check CI outputs and resolve issues. |
@redvinaa, your PR has failed to build. Please check CI outputs and resolve issues. |
55be1a2
to
dd67e94
Compare
@redvinaa, your PR has failed to build. Please check CI outputs and resolve issues. |
This pull request is in conflict. Could you fix it @redvinaa? |
Signed-off-by: redvinaa <[email protected]>
Signed-off-by: redvinaa <[email protected]>
Signed-off-by: redvinaa <[email protected]>
Signed-off-by: redvinaa <[email protected]>
Signed-off-by: redvinaa <[email protected]>
Signed-off-by: redvinaa <[email protected]>
Signed-off-by: redvinaa <[email protected]>
Signed-off-by: redvinaa <[email protected]>
Signed-off-by: redvinaa <[email protected]>
Signed-off-by: redvinaa <[email protected]>
Signed-off-by: redvinaa <[email protected]>
Signed-off-by: redvinaa <[email protected]>
@SteveMacenski can you take a look at 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: