Feature: Add features for better node element parsing#16
Merged
robin-mueller merged 4 commits intomasterfrom Feb 12, 2026
Merged
Feature: Add features for better node element parsing#16robin-mueller merged 4 commits intomasterfrom
robin-mueller merged 4 commits intomasterfrom
Conversation
…veFirstNode with an option to set a flag for enabling deep search
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request enhances the behavior tree core API with better node element traversal, manipulation, and blackboard remapping functionality. The main improvements include adding recursive (deep) search capabilities to node finding and removal operations, introducing a standard iterator interface for traversing node children, providing direct XML element access for advanced use cases, and improving the SubTree node's blackboard remapping API for better clarity and usability.
Changes:
- Added
deep_searchparameter togetFirstNode()andremoveFirstChild()methods, enabling recursive search/removal throughout all descendants instead of just direct children - Introduced
ChildIteratorclass withbegin()/end()methods for standard C++ iteration over direct children of a node - Added
getXMLElement()method for direct access to underlying XML elements in advanced scenarios - Changed
SubTree::setBlackboardRemapping()to acceptstd::map<std::string, std::string>instead ofPortValues, and addedgetBlackboardRemapping()for retrieving current mappings - Explicitly deleted child-related methods in
LeafNodeModelTypeto prevent misuse - Refactored test utilities into shared header for better code reuse
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| auto_apms_behavior_tree_core/include/auto_apms_behavior_tree_core/tree/tree_document.hpp | Adds ChildIterator class definition, deep_search parameters to method signatures, and getXMLElement() declaration |
| auto_apms_behavior_tree_core/include/auto_apms_behavior_tree_core/node/node_model_type.hpp | Updates macro to propagate deep_search parameter, adds deleted methods to LeafNodeModelType, and updates SubTree blackboard remapping signatures |
| auto_apms_behavior_tree_core/src/tree/tree_document.cpp | Implements ChildIterator, updates removeFirstChild to use Parent()->DeleteChild for deep search compatibility, adds shallow iteration to getFirstNode, and implements getXMLElement() |
| auto_apms_behavior_tree_core/src/node/node_model_type.cpp | Updates setBlackboardRemapping signature and implements getBlackboardRemapping |
| auto_apms_behavior_tree_core/test/unit/testable_tree_document.hpp | Extracts TestableTreeDocument helper class into shared header for reuse across test files |
| auto_apms_behavior_tree_core/test/unit/tree_document_tree_generation.cpp | Removes inline TestableTreeDocument definition and includes shared header instead |
| auto_apms_behavior_tree_core/test/unit/tree_document_node_element.cpp | Adds comprehensive tests for ChildIterator, getFirstNode with deep_search, and removeFirstChild with deep_search |
| auto_apms_behavior_tree/test/unit/tree_document_model_templates.cpp | Adds comprehensive tests for template-based node operations including deep_search functionality |
| auto_apms_behavior_tree_core/CMakeLists.txt | Registers new test file tree_document_node_element.cpp |
| auto_apms_behavior_tree/CMakeLists.txt | Registers new test file tree_document_model_templates.cpp |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several enhancements and API improvements to the behavior tree core, primarily focused on node traversal, manipulation, and blackboard remapping functionality. The main changes include adding support for recursive (deep) search and removal of nodes, introducing direct access to underlying XML elements, and expanding the public API for iterating over node children. Additionally, the SubTree node's blackboard remapping interface has been improved for clarity and usability.
API Enhancements for Node Traversal and Manipulation:
deep_searchparameter togetFirstNodeandremoveFirstChildmethods (and their template counterparts) inNodeElementandTreeElement, allowing recursive search/removal of nodes throughout all descendants, not just direct children. This change is reflected in both method signatures and documentation. [1] [2] [3] [4] [5] [6] [7] [8]ChildIteratorclass and correspondingbegin()/end()methods toNodeElement, enabling standard forward iteration over direct children of a node.tinyxml2::XMLElementfor advanced use cases, with an explicit warning about potential risks.SubTree Blackboard Remapping Improvements:
SubTree::setBlackboardRemappingmethod to accept a standardstd::map<std::string, std::string>instead of the previousPortValuestype, and added a newgetBlackboardRemappingmethod to retrieve the current mapping. [1] [2] [3]API Consistency and Restrictions:
LeafNodeModelTypeto prevent incorrect usage (e.g.,removeFirstChild,hasChildren,getFirstNode,begin,end,deepApply, etc.), clarifying that leaf nodes cannot have children.Testing:
tree_document_model_templates.cppandtree_document_node_element.cppto ensure coverage of the enhanced functionality. [1] [2]