BehaviorTree/BehaviorTree.CPP

GitHub: BehaviorTree/BehaviorTree.CPP

基于 C++17 的行为树框架,为机器人、游戏 AI 及自动化场景提供灵活、响应式的复杂决策逻辑编排能力。

Stars: 3926 | Forks: 821

![License MIT](https://img.shields.io/github/license/BehaviorTree/BehaviorTree.CPP?color=blue) [![conan Ubuntu](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/380105b3a2100530.svg)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/cmake_ubuntu.yml) [![conan Windows](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/4cab8a13df100531.svg)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/cmake_windows.yml) [![ros2](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/80836af2e6100532.svg)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/ros2.yaml) [![pixi (Conda)](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/690c50444d100533.svg)](https://github.com/BehaviorTree/BehaviorTree.CPP/actions/workflows/pixi.yaml) [![Coverage Status](https://coveralls.io/repos/github/BehaviorTree/BehaviorTree.CPP/badge.svg?branch=master)](https://coveralls.io/github/BehaviorTree/BehaviorTree.CPP?branch=master) # BehaviorTree.CPP 4.9

这个 __C++ 17__ 库提供了一个创建 BehaviorTree(行为树)的框架。 它的设计旨在灵活、易用、响应式且快速。 即使我们的主要用例是 __机器人技术__,你也可以使用此库来构建 __游戏 AI__,或替代有限状态机。 与其他实现相比,__BehaviorTree.CPP__ 具有一些独特的功能: - 它将 __异步 Actions__,即非阻塞操作,作为一等公民。 - 你可以构建并发执行多个 Actions 的 __响应式__ 行为(正交性)。 - 树是使用领域特定 __脚本语言__(基于 XML)定义的,并且可以在运行时加载;换句话说,即使是用 C++ 编写的,树的形态也 _不是_ 硬编码的。 - 你可以静态链接自定义 TreeNodes 或将其转换为 __插件__, 并在运行时加载它们。 - 它提供了一种类型安全且灵活的机制,用于在树的节点之间执行 __数据流__ (Dataflow)。 - 它包含一个 __日志/性能分析__ 基础设施,允许用户 可视化、记录、回放和分析状态转换。 ## 文档 - **教程和通用文档**:https://www.behaviortree.dev/ - **自动生成的 Doxygen**:https://behaviortree.github.io/BehaviorTree.CPP/ - **社区支持和论坛**:https://github.com/BehaviorTree/BehaviorTree.CPP/discussions # GUI 编辑器 编辑 BehaviorTree 就像在你喜欢的文本编辑器中编辑 XML 文件一样简单。 如果你正在寻找更棒的图形用户界面(我知道你是),请查看 [Groot2](https://www.behaviortree.dev/groot)。 ![Groot screenshot](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/bf7f93aaaa100534.png) # 如何编译 **BT.CPP** 需要支持 C++17 的编译器。 支持三种构建系统: - **colcon (ament)**,如果你使用 ROS2 - **conan**,否则(Linux/Windows)。 - **straight cmake**,如果你想亲自负责依赖管理 :) 使用 [conan](https://conan.io/) 编译: 假设你位于 `BehaviorTree.CPP` 的 **根** 目录下: ``` conan install . -s build_type=Release --build=missing cmake --preset conan-release cmake --build --preset conan-release ``` 如果你已经安装了 ZeroMQ 和 SQlite 等依赖项,并且不想 使用 conan,只需输入: ``` mkdir build_release cmake -S . -B build_release cmake --build build_release --parallel ``` 如果你想在 [pixi](https://pixi.sh/) 项目(conda 虚拟环境)中构建。 ``` pixi run build ``` 如果你想在你的应用程序中使用 BT.CPP,请参考 此处的示例:https://github.com/BehaviorTree/btcpp_sample 。 ## 安装 BehaviorTree.CPP (vcpkg) 或者,你可以使用 [vcpkg](https://github.com/Microsoft/vcpkg/) 依赖管理器构建并安装 behaviortree-cpp: ``` git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install ./vcpkg install behaviortree-cpp ``` vcpkg 中的 behaviortree-cpp 端口由 Microsoft 团队成员和社区贡献者保持更新。如果版本过时,请在 vcpkg 仓库中 [创建 issue 或 pull request](https://github.com/Microsoft/vcpkg)。 # 商业支持 你是否在商业产品中使用 BT.CPP,并且需要技术支持/咨询? 你可以联系主要作者 **dfaconti@aurynrobotics.com** 来讨论你的用例和需求。 ## 以前的版本 软件的 3.8 版本可以在 [v3.8](https://github.com/BehaviorTree/BehaviorTree.CPP/tree/v3.8) 分支中找到。 该分支可能会收到错误修复,但新功能将仅 在 master 分支中实现。 # 许可证 The MIT License (MIT) Copyright (c) 2019-2026 Davide Faconti Copyright (c) 2018-2019 Davide Faconti, Eurecat Copyright (c) 2014-2018 Michele Colledanchise Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
标签:Android, Bash脚本, Behavior Trees, BurpSuite集成, C++17, C++库, DSL, FSM, HTTP头分析, MIT许可, ROS2, XML, 人工智能, 决策系统, 反应式系统, 并发, 开源库, 异步编程, 控制逻辑, 搜索引擎爬虫, 有限状态机, 机器人, 机器人操作系统, 游戏AI, 游戏开发, 状态机, 用户模式Hook绕过, 脚本加载, 自动化控制, 行为树, 软件架构, 领域特定语言