Home
翻译自:https://www.behaviortree.dev
Home
About this library [关于此库]
This C++ library provides a framework to create BehaviorTrees.It was designed to be flexible, easy to use and fast. [这个 C++ 库提供了一个创建行为树的框架。它被设计为灵活、易于使用和快速。]
Even if our main use-case is robotics, you can use this library to build AI for games, or to replace Finite State Machines in you application. [即使我们的主要用例是__机器人__,您也可以使用此库构建__游戏AI__,或替换应用程序中的有限状态机。]
BehaviorTree.CPP has many interesting features, when compared to other implementations: [与其他实现相比,BehaviorTree.CPP 有许多有趣的特性:]
- It makes asynchronous Actions, i.e. non-blocking routines, a first-class citizen. [它使异步操作(即非阻塞例程)成为一等公民。]
- It allows the creation of trees at run-time, using a textual representation (XML). [它允许在运行时使用文本表示 (XML) 创建树。]
- You can link staticaly your custom TreeNodes or convert them into plugins
which are loaded at run-time. [您可以静态链接您的自定义 TreeNode 或将它们转换为在运行时加载的插件。] - It includes a logging/profiling infrastructure that allows the user to visualize, record, replay and analyze state transitions. [它包括一个__日志/分析__基础设施,允许用户可视化、记录、回放和分析状态转换。]
Community [社区]
If this documentation doesn’t answer your questions or if you simply want to connect with the community of BT.CPP users, visit discourse.behaviortree.dev. [如果本文档没有回答您的问题,或者您只是想与 BT.CPP 用户社区建立联系,请访问 discourse.behaviortree.dev。]
What is a Behavior Tree? [什么是行为树?]
A Behavior Tree (BT) is a way to structure the switching between different tasks in an autonomous agent, such as a robot or a virtual entity in a computer game. [行为树 (BT) 是一种在自主代理中构建不同任务之间切换的方法,例如计算机游戏中的机器人或虚拟实体。]
BTs are a very efficient way of creating complex systems that are both modular and reactive. These properties are crucial in many applications, which has led to the spread of BT from computer game programming to many branches of AI and Robotics. [BT 是创建模块化和反应式的复杂系统的一种非常有效的方法。这些属性在许多应用中至关重要,这导致 BT 从计算机游戏编程扩展到 AI 和机器人技术的许多分支。]
If you are already familiar with Finite State Machines (FSM), you will easily grasp most of the concepts but, hopefully, you will find that BTs are more expressive and easier to reason about.[如果您已经熟悉有限状态机 (FSM),您将轻松掌握大部分概念,但希望您会发现 BT 更具表现力且更易于推理。]
The main advantages of Behavior Trees, when compared to FSMs are: [与 FSM 相比,行为树的主要优点是:]
-
They are intrinsically Hierarchical: this means that we can compose complex behaviors including entire trees as sub-branches of a bigger tree. For instance, the behavior “Fetch Beer” may reuse the tree “Grasp Object”. [它们本质上是分层的:这意味着我们可以组合复杂的行为,包括整个树作为更大树的子分支。例如,行为“Fetch Beer”可以重用树“Grasp Object”。]
-
Their graphical representation has a semantic meaning: it is easier to “read” a BT and understand the corresponding workflow. State transitions in FSMs, by comparisons, are harder to understand both in their textual and graphical representation. [它们的图形表示具有语义含义:更容易“阅读”BT 并理解相应的工作流程。相比之下,FSM 中的状态转换在文本和图形表示中都更难理解。]
-
They are more expressive: Ready to use ControlNodes and DecoratorNodes make possible to express more complex control flows. The user can extend the “vocabulary” with his/her own custom nodes. [它们更具表现力:准备使用 ControlNodes 和 DecoratorNodes 可以表达更复杂的控制流。用户可以用他/她自己的自定义节点扩展“词汇表”。]
“Ok, but WHY do we need BehaviorTrees (or FSM)?” [“好的,但是为什么我们需要 BehaviorTrees(或 FSM)?”]
Many software systems, robotics being a notable example, are inherently complex. [许多软件系统,机器人技术就是一个显着的例子,本质上是复杂的。]
The usual approach to manage complexity, heterogeneity and scalability is to use the concept of Component Based Software Engineering. [管理复杂性、异构性和可扩展性的常用方法是使用基于组件的软件工程的概念。]
Any existing middleware for robotics took this approach either informally or formally, being ROS, YARP and SmartSoft some notable examples. [任何现有的机器人中间件都以非正式或正式的方式采用这种方法,如 ROS、YARP 和 SmartSoft 一些值得注意的例子。]
A “good” software architecture should have the following characteristics: [一个“好的”软件架构应该具有以下特征:]
- Modularity. [模块化]
- Reusability of components. [组件的可重用性]
- Composability. [可组合性]
- Good separation of concerns. [良好的关注点分离]
If we don’t keep these concepts in mind from the very beginning, we create software modules/components which are highly coupled to a particular application, instead of being reusable. [如果我们从一开始就没有牢记这些概念,我们就会创建与特定应用程序高度耦合的软件模块/组件,而不是可重用的。]
Frequently, the business logic is “spread” in many locations and it is hard for the developer to reason about it and to debug errors in the control flow. [通常,业务逻辑“散布”在许多地方,开发人员很难对其进行推理并调试控制流中的错误。]
To achieve strong separation of concerns it is better to centralize the business logic in a single location. [为了实现关注点的强分离,最好将业务逻辑集中在一个位置。]
Finite State Machines were created specifically with this goal in mind, but in the recent years Behavior Trees gained popularity, especially in the game industry. [__有限状态机__是专门为这一目标而创建的,但近年来__行为树__越来越受欢迎,尤其是在游戏行业。]