Skip to content

Conversation

@Jad-ELHAJJ
Copy link
Contributor


Basic Info

Info Please fill out this column
Ticket(s) this addresses N/A
Primary OS tested on Ubuntu
Does this PR contain AI generated software? No
Was this PR description generated by AI software? No

Description of contribution in a few bullet points

A fix PR making sure that BTCPP warning would never be logged. The final logic will be:

  • If a user has conflicting IDs and specifies a file name, only the Behavior Tree (BT) from that file will be loaded. Other trees with the same ID will be ignored. Subtree functionality will fail if subtrees have conflicting IDs.
  • If a user has unique IDs (no conflicts) and specifies a file name, all BTs are loaded, and the subtree feature works correctly.
  • If a user has unique IDs and specifies a BT ID, all BTs are loaded, and the subtree feature works correctly.
  • If a user has conflicting IDs and specifies a BT ID, an error is reported, but the system still attempts to load the BT corresponding to the specified ID.

Description of how this change was tested

  • Tested all 4 conditions listed above on a behavior tree that includes subtrees.
  • Tested with unit tests.

PS: codecov might complain about not covered code in bt_action_server_impl.hpp, but I added unit test for all 4 conditions. So the mock loadBehaviorTree in test_behavior_tree_node.cpp will be covering the new changes.


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
  • Should this be backported to current distributions? If so, tag with backport-*.
@codecov
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

❌ Patch coverage is 72.41379% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...clude/nav2_behavior_tree/bt_action_server_impl.hpp 72.41% 8 Missing ⚠️
Files with missing lines Coverage Δ
...clude/nav2_behavior_tree/bt_action_server_impl.hpp 88.54% <72.41%> (-1.86%) ⬇️

... and 7 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.

Pull in main / rebase in order for CI to pass

Jad-ELHAJJ and others added 12 commits October 16, 2025 11:12
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
…_impl.hpp

Signed-off-by: Steve Macenski <stevenmacenski@gmail.com>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
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.

LGTM now. Did you test this again that it works for the cases we had issue with before?

SteveMacenski and others added 3 commits October 16, 2025 14:07
…_impl.hpp

Signed-off-by: Steve Macenski <stevenmacenski@gmail.com>
…_impl.hpp

Signed-off-by: Steve Macenski <stevenmacenski@gmail.com>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
@Jad-ELHAJJ
Copy link
Contributor Author

LGTM now. Did you test this again that it works for the cases we had issue with before?

yes, we wont get the btcpp warning anymore :)

@SteveMacenski
Copy link
Member

+             RCLCPP_ERROR(logger_, "Skipping BT file %s (missing ID)", entry.path().c_str());
+             RCLCPP_WARN(logger_, "Skipping conflicting BT file %s (duplicate ID %s)",

-       tree_ = bt_->createTree(file_or_id, blackboard_);
+       // file_or_id is an ID: register all files, skipping conflicts
+       main_id = file_or_id;
+       register_all_bt_files();

Please cover these lines (these ones should be easy) for CI and I can merge, thanks!

Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
@Jad-ELHAJJ
Copy link
Contributor Author

+             RCLCPP_ERROR(logger_, "Skipping BT file %s (missing ID)", entry.path().c_str());
+             RCLCPP_WARN(logger_, "Skipping conflicting BT file %s (duplicate ID %s)",

-       tree_ = bt_->createTree(file_or_id, blackboard_);
+       // file_or_id is an ID: register all files, skipping conflicts
+       main_id = file_or_id;
+       register_all_bt_files();

Please cover these lines (these ones should be easy) for CI and I can merge, thanks!

All use cases are now covered :-)

@SteveMacenski
Copy link
Member

@Jad-ELHAJJ please check out https://app.codecov.io/gh/ros-navigation/navigation2/pull/5594 there are lots of gaps still that this didn't cover. They mostly seems easy to solve with unit tests

  • Using is_bt_id to cover the else case
  • registered_ids.count(id) having duplicate names to trigger this continuance
  • id.empty() providing an ID-less tree
  • Optional: const std::exception & e if you can get it to throw some way, exercising this would be nice
@Jad-ELHAJJ
Copy link
Contributor Author

@Jad-ELHAJJ please check out https://app.codecov.io/gh/ros-navigation/navigation2/pull/5594 there are lots of gaps still that this didn't cover. They mostly seems easy to solve with unit tests

  • Using is_bt_id to cover the else case
  • registered_ids.count(id) having duplicate names to trigger this continuance
  • id.empty() providing an ID-less tree
  • Optional: const std::exception & e if you can get it to throw some way, exercising this would be nice

Check test_behavior_tree_node.cpp

  • The ID specified (else branch) is covered by TestAllUniqueIDsWithIDSpecified and TestDuplicateIDsWithIDSpecified.
  • Duplicate ID detection is verified by TestDuplicateIDsWithFileSpecified and TestDuplicateIDsWithIDSpecified.
  • The missing ID case is handled by TestSkipFilesWithMissingID.
@SteveMacenski SteveMacenski merged commit 00dfd67 into ros-navigation:main Oct 22, 2025
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants