BehaviorTree.CPP is a C++17 library for building behavior trees for robotics, games, or state-machine-style control. Trees load from XML at runtime with async actions and logging built in.
Overview
BehaviorTree.CPP provides a framework to author and run behavior trees in modern C++. It targets reactive control for robots but can also drive game AI or replace finite state machines. The design treats non-blocking asynchronous actions as first-class and supports concurrent orthogonal behaviors.
Trees are described in an XML-based domain language and can be loaded at runtime instead of hard-coding structure in C++. Custom nodes may be linked statically or loaded as plugins. A type-safe dataflow mechanism passes data between nodes, and logging tools help visualize, record, replay, and profile transitions.
The library integrates with ROS2 workflows while remaining usable outside ROS. Optional Groot2 offers a graphical editor and live monitoring. Builds are supported through CMake, Conan, or colcon for ROS2 environments, and packages are available via vcpkg.
Documentation includes tutorials, Doxygen API reference, and community forums for support.
Key features
- XML-defined runtime-loaded trees
- Async non-blocking action nodes
- Orthogonal concurrent behaviors
- Plugin or static custom nodes
- Type-safe inter-node dataflow
- Logging, record, and replay
- ROS2-oriented build via colcon
- Groot2 visual editor companion
Use cases
- Robot deliberation and navigation logic
- Game AI behavior authoring
- Replacing finite state machines
- ROS2 behavior tree integration
- Debuggable modular control flows