Abstract
There is a growing interest in Behavior Trees (BTs) as a tool to describe and implement robot behaviors. BTs were devised in the video game industry and their adoption in robotics resulted in the development of ad-hoc libraries to design and execute BTs that fit complex robotics software architectures. While there is broad consensus on how BTs work, some characteristics rely on the implementation choices done in the specific software library used. In this letter, we outline practical aspects in the adoption of BTs and the solutions devised by the robotics community to fully exploit the advantages of BTs in real robots. We also overview the solutions proposed in open-source libraries used in robotics, we show how BTs fit in robotic software architecture, and we present a use case example.
Introduction: From NPCs to Real Robots
Behavior Trees (BTs) have transitioned from controlling non-player characters (NPCs) in video games to becoming a robust alternative to Finite State Machines (FSMs) in robotics. Their appeal lies in their modularity, flexibility, and ease of reuse. However, physical robots operate in uncertain, high-latency environments where actions—such as navigating a room or grasping an object—take significant time and are prone to complex failures.
Implementing BTs in robotics requires addressing three fundamental challenges:
- Asynchronicity: Managing high-frequency "ticks" while executing long-duration actions.
- Reactivity: Safely interrupting ongoing actions when higher-priority conditions change.
- Data Flow: Efficiently sharing state information across nodes without compromising modularity.
Implementation Patterns for Robotic BTs
To bridge the gap between virtual agents and physical hardware, several implementation patterns have emerged to make BTs "robot-ready."
Composition Nodes and Memory
Standard BTs can be "reactive," re-evaluating every condition on every tick. While this ensures responsiveness, it can be computationally expensive. "Stateful" nodes or nodes with memory (e.g., Sequence with Memory) allow a robot to remember successful sub-tasks, preventing redundant operations like re-detecting an already localized object.
Asynchronous Execution and Halting
Robotic actions are inherently asynchronous. The authors highlight Coroutines as an effective mechanism to yield control back to the BT engine without blocking execution. Furthermore, a formal Halt() or Abort() procedure is essential. This ensures that when a task is preempted, the robot transitions to a stable state rather than stopping abruptly in a potentially dangerous configuration.
Architectural Integration
The paper proposes a four-layer model to integrate BTs into robotic stacks:
- Mission Layer: Defines high-level goals (e.g., "Serve a customer").
- Task Layer: The BT logic itself.
- Skill Layer: The implementation of leaf nodes (e.g., "Grasp Object").
- Service Layer: Low-level drivers and middleware like ROS.
A key architectural tension exists between reactivity and memory. While memory nodes improve efficiency, they can make a robot "blind" to environmental changes. Similarly, the "Blackboard" pattern for data sharing must be managed carefully; the authors suggest scoped variables or middleware parameter servers to maintain modularity in large-scale trees.
Library Analysis and Use Case
A comparison of six open-source libraries reveals that BehaviorTree.CPP is currently the most feature-complete for robotics, offering support for both classical and memory nodes, explicit port-based data flow, and coroutine-based asynchronicity.
The effectiveness of these principles is demonstrated through a "Fetch and Deliver" use case on a humanoid robot. By orchestrating reusable "Skills" through a high-level reactive BT, complex behaviors become manageable and robust.
Conclusion and Future Directions
While BTs offer significant advantages over FSMs in terms of readability and maintenance, challenges remain. The "blocking" nature of halting procedures can introduce delays, and formal verification of safety in complex BTs is an ongoing area of research. Additionally, the maturity of visual design and debugging tools for robotics-specific BTs still lags behind their gaming counterparts. Nonetheless, the formalization of these implementation choices provides a clear roadmap for building more capable and reactive robotic systems.
Summary updated