Getting started

翻译自:https://www.behaviortree.dev

Getting started [入门]

BehaviorTree.CPP is a C++ library that can be easily integrated into your favourite distributed middleware, such as ROS or SmartSoft. You can statically link it into your application (for example a game). [BehaviorTree.CPP 是一个 C++ 库,可以轻松集成到您喜欢的分布式中间件中,例如 ROSSmartSoft]

These are the main concepts which you need to understand first. [这些是您首先需要了解的主要概念。]

Nodes vs Trees [节点与树]

The user must create his/her own ActionNodes and ConditionNodes (LeafNodes); this library helps you to compose them easily into trees. [用户必须创建自己的 ActionNodes 和 ConditionNodes (LeafNodes);该库可帮助您轻松地将它们组合成树。]

Think about the LeafNodes as the building blocks which you need to compose a complex system. [将 LeafNode 视为组成复杂系统所需的构建块。]

By definition, your custom Nodes are (or should be) highly reusable. But, at the beginning, some wrapping interfaces might be needed to adapt your legacy code. [根据定义,您的自定义节点是(或应该)高度__可重用__的。但是,在开始时,可能需要一些包装接口来适应您的遗留代码。]

The tick() callbacks [tick() 回调]

Any TreeNode can be seen as a mechanism to invoke a callback, i.e. to run a piece of code. What this callback does is up to you. [任何 TreeNode 都可以看作是一种调用回调的机制,即运行一段代码。这个回调做什么取决于你。]

In most of the following tutorials, our Actions will simply print messages on console or sleep for a certain amount of time to simulate a long calculation. [在以下大部分教程中,我们的 Actions 将简单地在控制台上打印消息或休眠一段时间以模拟长时间的计算。]

In production code, especially in Model Driven Development and Component Based Software Engineering, an Action/Condition would probably communicate to other components or services of the system. [在生产代码中,尤其是在模型驱动开发和基于组件的软件工程中,动作/条件可能会与系统的其他组件或服务进行通信。]

Inheritance vs dependency injection. [继承与依赖注入。]

To create a custom TreeNode, you should inherit from the proper class. [要创建自定义 TreeNode,您应该从正确的类继承。]

For instance, to create your own synchronous Action, you should inherit from the class SyncActionNode. [例如,要创建自己的同步动作,您应该从类 __SyncActionNode __继承。]

Alternatively, the library provides a mechanism to create a TreeNode passing a function pointer to a wrapper (dependency injection). [或者,该库提供了一种创建 TreeNode 的机制,将__函数指针__传递给包装器(依赖注入)。]

This approach reduces the amount of boilerplate in your code; as a reference please look at the first tutorial. [这种方法减少了代码中的样板数量;作为参考,请查看第一个教程]

Dataflow, Ports and Blackboard [数据流、端口和黑板]

Ports are explained in detail in the second and third tutorials. [端口在第二篇和第三篇教程中有详细解释。]

For the time being, it is important to know that: [目前,重要的是要知道:]

  • A Blackboard is a key/value storage shared by all the Nodes of a Tree. [__黑板__是树的所有节点共享的键/值存储。]

  • Ports are a mechanism that Nodes can use to exchange information between each other. [端口是节点可以用来在彼此之间交换信息的一种机制。]

  • Ports are “connected” using the same key of the blackboard. [端口使用黑板上的相同键“连接”。]

  • The number, name and kind of ports of a Node must be known at compilation-time (C++); connections between ports are done at deployment-time (XML). [节点的数量、名称和端口类型必须在编译时知道(C++);端口之间的连接在部署时 (XML) 完成。]

Load trees at run-time using the XML format [使用 XML 格式在运行时加载树]

Despite the fact that the library is written in C++, trees themselves can be composed at run-time, more specifically, at deployment-time, since it is done only once at the beginning to instantiate the Tree. [尽管库是用 C++ 编写的,但树本身可以在运行时组合,更具体地说,在部署时组合,因为它在开始时只完成一次实例化树。]

An XML format is described in details here. [此处详细描述了 XML 格式。]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值