Skip to content

Refactor: Tree executor modularity#18

Merged
robin-mueller merged 15 commits intomasterfrom
feature/event-based-executor
Mar 6, 2026
Merged

Refactor: Tree executor modularity#18
robin-mueller merged 15 commits intomasterfrom
feature/event-based-executor

Conversation

@robin-mueller
Copy link
Member

This pull request introduces a new template class to support action-based triggering of behavior tree execution, and refactors the codebase to use this new abstraction. The most significant change is the addition of the ActionBasedTreeExecutorNode template, which generalizes the logic for executing behavior trees in response to custom ROS 2 action goals. This allows for more flexible and reusable executor nodes. The executor_node.hpp now uses this new template, simplifying its implementation and removing the previous custom options class.

Key changes:

New Action-based Executor Abstraction:

  • Introduced the ActionBasedTreeExecutorNode template class in executor/action_based_executor_node.hpp, providing a generic mechanism for executing behavior trees triggered by arbitrary ROS 2 action goals. This class manages goal acceptance, execution lifecycle, and result handling, and is intended to be subclassed for specific action types.

Refactoring and Simplification:

  • Updated executor_node.hpp to use the new ActionBasedTreeExecutorNode template with the built-in StartTreeExecutor action type, removing the previous TreeExecutorNodeOptions class and related configuration logic. This greatly simplifies the executor node interface and implementation.

Build System Updates:

  • Added new source files src/executor/options.cpp and src/executor/generic_executor_node.cpp to the library build list in CMakeLists.txt, supporting the new executor node architecture.

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 PR refactors the behavior tree executor architecture to improve modularity by introducing a reusable action-triggered executor template and moving shared executor logic into a generic base, while updating the existing TreeExecutorNode to use the new abstractions.

Changes:

  • Added ActionBasedTreeExecutorNode<ActionT> to generalize “action goal → tree execution” behavior.
  • Introduced GenericTreeExecutorNode + TreeExecutorNodeOptions as shared infrastructure (parameters, build handler loading, command action, blackboard sync).
  • Extended TreeBuilder with an instantiate(TreeElement, ...) overload and updated build configuration to compile the new sources.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
auto_apms_behavior_tree_core/src/builder.cpp Adds TreeBuilder::instantiate(TreeElement, ...) implementation.
auto_apms_behavior_tree_core/include/auto_apms_behavior_tree_core/builder.hpp Declares the new instantiate(TreeElement, ...) API and updates docs.
auto_apms_behavior_tree/src/executor/options.cpp Implements extracted executor options class.
auto_apms_behavior_tree/src/executor/generic_executor_node.cpp Adds the new generic executor implementation (params, build handler, command action, sync).
auto_apms_behavior_tree/src/executor/executor_node.cpp Refactors TreeExecutorNode to use the new action-based executor template and generic base.
auto_apms_behavior_tree/include/auto_apms_behavior_tree/util/node.hpp Adds #pragma once.
auto_apms_behavior_tree/include/auto_apms_behavior_tree/executor/options.hpp Introduces TreeExecutorNodeOptions header.
auto_apms_behavior_tree/include/auto_apms_behavior_tree/executor/generic_executor_node.hpp Introduces GenericTreeExecutorNode interface and allowed-parameter lists.
auto_apms_behavior_tree/include/auto_apms_behavior_tree/executor/executor_node.hpp Refactors public TreeExecutorNode API to inherit from ActionBasedTreeExecutorNode.
auto_apms_behavior_tree/include/auto_apms_behavior_tree/executor/action_based_executor_node.hpp Introduces the reusable action-triggered executor template.
auto_apms_behavior_tree/CMakeLists.txt Adds new executor sources to the library build.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

robin-mueller and others added 4 commits March 6, 2026 14:17
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Mar 6, 2026

@robin-mueller I've opened a new pull request, #19, to work on those changes. Once the pull request is ready, I'll request review from you.

robin-mueller and others added 5 commits March 6, 2026 14:25
…dition

Co-authored-by: robin-mueller <83639955+robin-mueller@users.noreply.github.com>
Fix race condition in ActionBasedTreeExecutorNode: per-goal TreeConstructor storage via UUID map
@robin-mueller robin-mueller merged commit 3fa2a4b into master Mar 6, 2026
7 checks passed
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.

3 participants