Skip to content

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

redvinaa
Copy link
Contributor

@redvinaa redvinaa commented Jun 9, 2025

Basic Info

Info Please fill out this column
Ticket(s) this addresses (add tickets here #5213)
Primary OS tested on Ubuntu
Robotic platform tested on custom robot
Does this PR contain AI generated software? No

Description of contribution in a few bullet points

Description of documentation updates required from your changes

  • Headers are well-documented
  • Added 2 new control nodes, they need to be described in the docs with examples (create mwe from the code in the discussion)

Description of how this change was tested

  • Have been using for a long time on humble, now on jazzy
  • Haven't tested on rolling, because I don't have a rolling stack

Future work that may be required in bullet points

  • Tests still need to be written for both BT nodes!

For Maintainers:

  • Check that any new parameters added are updated in docs.nav2.org
  • Check that any significant change is added to the migration guide
  • Check that any new features OR changes to existing behaviors are reflected in the tuning guide
  • Check that any new functions have Doxygen added
  • Check that any new features have test coverage
  • Check that any new plugins is added to the plugins page
  • If BT Node, Additionally: add to BT's XML index of nodes for groot, BT package's readme table, and BT library lists

Copy link

codecov bot commented Jun 9, 2025

Codecov Report

Attention: Patch coverage is 6.14525% with 168 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
nav2_behavior_tree/plugins/control/pause.cpp 1.47% 134 Missing ⚠️
...lugins/control/sequence_with_blackboard_memory.cpp 5.71% 33 Missing ⚠️
...lugins/control/sequence_with_blackboard_memory.hpp 75.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
...clude/nav2_behavior_tree/plugins/control/pause.hpp 100.00% <100.00%> (ø)
...lugins/control/sequence_with_blackboard_memory.hpp 75.00% <75.00%> (ø)
...lugins/control/sequence_with_blackboard_memory.cpp 5.71% <5.71%> (ø)
nav2_behavior_tree/plugins/control/pause.cpp 1.47% <1.47%> (ø)

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@SteveMacenski SteveMacenski left a 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
Copy link
Member

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 :-)

Copy link
Member

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 :-)

@@ -390,6 +390,15 @@

<Control ID="RoundRobin"/>

<Control ID="Pause">
Copy link
Member

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

BT::NodeStatus Pause::tick()
{
unsigned int children_count = children_nodes_.size();
if (children_count < 1 || children_count > 4) {
Copy link
Member

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 added 2 commits June 10, 2025 11:22
Signed-off-by: redvinaa <redvinaa@gmail.com>
Signed-off-by: redvinaa <redvinaa@gmail.com>
Signed-off-by: redvinaa <redvinaa@gmail.com>
Copy link
Contributor

mergify bot commented Jun 10, 2025

@redvinaa, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@redvinaa
Copy link
Contributor Author

Woah, this suddenly became more serious than I expected :D
I still have to write the tests and make this work with my jazzy stack, so it might take some time.

Copy link
Member

@SteveMacenski SteveMacenski left a 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_;
Copy link
Member

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");
Copy link
Member

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");
Copy link
Member

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">
Copy link
Member

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_);
Copy link
Member

@SteveMacenski SteveMacenski Jun 10, 2025

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_);
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants