Skip to content

Feature: Add features for better node element parsing#16

Merged
robin-mueller merged 4 commits intomasterfrom
feature/node-element-iteration
Feb 12, 2026
Merged

Feature: Add features for better node element parsing#16
robin-mueller merged 4 commits intomasterfrom
feature/node-element-iteration

Conversation

@robin-mueller
Copy link
Collaborator

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:

  • Added a deep_search parameter to getFirstNode and removeFirstChild methods (and their template counterparts) in NodeElement and TreeElement, 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]
  • Introduced a ChildIterator class and corresponding begin()/end() methods to NodeElement, enabling standard forward iteration over direct children of a node.
  • Added a method to retrieve a pointer to the underlying tinyxml2::XMLElement for advanced use cases, with an explicit warning about potential risks.

SubTree Blackboard Remapping Improvements:

  • Changed the SubTree::setBlackboardRemapping method to accept a standard std::map<std::string, std::string> instead of the previous PortValues type, and added a new getBlackboardRemapping method to retrieve the current mapping. [1] [2] [3]

API Consistency and Restrictions:

  • Explicitly deleted child traversal and manipulation methods for LeafNodeModelType to prevent incorrect usage (e.g., removeFirstChild, hasChildren, getFirstNode, begin, end, deepApply, etc.), clarifying that leaf nodes cannot have children.

Testing:

  • Added new unit tests for tree_document_model_templates.cpp and tree_document_node_element.cpp to ensure coverage of the enhanced functionality. [1] [2]

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_search parameter to getFirstNode() and removeFirstChild() methods, enabling recursive search/removal throughout all descendants instead of just direct children
  • Introduced ChildIterator class with begin()/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 accept std::map<std::string, std::string> instead of PortValues, and added getBlackboardRemapping() for retrieving current mappings
  • Explicitly deleted child-related methods in LeafNodeModelType to 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.

@robin-mueller robin-mueller merged commit 3e96e46 into master Feb 12, 2026
13 checks passed
@robin-mueller robin-mueller self-assigned this Feb 13, 2026
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.

1 participant