diff --git a/thirdparty/behaviortree/BUILD.gn b/thirdparty/behaviortree/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d9fe5ab8a22066f435e5edca1d5a413246c760af --- /dev/null +++ b/thirdparty/behaviortree/BUILD.gn @@ -0,0 +1,840 @@ +/* + * Copyright (c) 2023, HiHope Community. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import("//build/ohos.gni") + +declare_args() { + enable_behaviortree_test = false +} + +config("public_config"){ + ldflags = [ + "-Wl", + "-lm", + "-lc", + "-lpthread", + ] + +} + +config("lexy_file_config"){ + cflags_cc = [ + "-O3", + "-DNDEBUG", + "-Wpedantic", + "-pedantic-errors", + "-Werror", + "-Wall", + "-Wextra", + "-Wconversion", + "-Wsign-conversion", + "-Wno-parentheses", + "-Wno-unused-local-typedefs", + "-Wno-array-bounds", + "-Wno-maybe-uninitialized", + "-Wno-restrict", + "-std=gnu++20", + ] +} + +ohos_static_library("lexy_file") { + output_name = "lexy_file" + + sources = [ + "BehaviorTree.CPP/3rdparty/lexy/src/input/file.cpp", + ] + + defines = [ + ] + + configs = [ + ":lexy_file_config", + ":public_config", + ] + + include_dirs = [ + "BehaviorTree.CPP/3rdparty/lexy/include", + ] + + part_name = "behaviortree" +} + +config("bt_sample_nodes_config"){ + cflags_cc = [ + "-O3", + "-DNDEBUG", + "-Wpedantic", + "-std=gnu++17", + "-fexceptions", + "-frtti", + "-Wno-unused-function", + ] +} + +ohos_static_library("bt_sample_nodes") { + sources = [ + "BehaviorTree.CPP/sample_nodes/crossdoor_nodes.cpp", + "BehaviorTree.CPP/sample_nodes/dummy_nodes.cpp", + "BehaviorTree.CPP/sample_nodes/movebase_node.cpp", + ] + + defines = [ + ] + + configs = [ + ":bt_sample_nodes_config", + ":public_config", + ] + + include_dirs = [ + "BehaviorTree.CPP/include", + "BehaviorTree.CPP/sample_nodes" + ] + + part_name = "behaviortree" +} + +config("behaviortreecpp_config"){ + cflags_cc = [ + "-O3", + "-DNDEBUG", + "-fPIC", + "-Wpedantic", + "-Wall", + "-Wextra", + "-std=gnu++20", + "-fexceptions", + "-frtti", + "-Wno-deprecated-volatile", + "-Wno-unused-lambda-capture", + ] + + include_dirs = [ + "BehaviorTree.CPP/.", + "BehaviorTree.CPP/include", + "BehaviorTree.CPP/3rdparty", + "BehaviorTree.CPP/3rdparty/lexy/include", + ] + +} + +ohos_shared_library("behaviortree_cpp") { + output_name = "behaviortree_cpp" + + sources = [ + "BehaviorTree.CPP/src/action_node.cpp", + "BehaviorTree.CPP/src/basic_types.cpp", + "BehaviorTree.CPP/src/behavior_tree.cpp", + "BehaviorTree.CPP/src/blackboard.cpp", + "BehaviorTree.CPP/src/bt_factory.cpp", + "BehaviorTree.CPP/src/decorator_node.cpp", + "BehaviorTree.CPP/src/condition_node.cpp", + "BehaviorTree.CPP/src/control_node.cpp", + "BehaviorTree.CPP/src/shared_library.cpp", + "BehaviorTree.CPP/src/tree_node.cpp", + "BehaviorTree.CPP/src/script_parser.cpp", + "BehaviorTree.CPP/src/json_export.cpp", + "BehaviorTree.CPP/src/xml_parsing.cpp", + "BehaviorTree.CPP/src/actions/test_node.cpp", + "BehaviorTree.CPP/src/decorators/inverter_node.cpp", + "BehaviorTree.CPP/src/decorators/repeat_node.cpp", + "BehaviorTree.CPP/src/decorators/retry_node.cpp", + "BehaviorTree.CPP/src/decorators/subtree_node.cpp", + "BehaviorTree.CPP/src/decorators/delay_node.cpp", + "BehaviorTree.CPP/src/controls/if_then_else_node.cpp", + "BehaviorTree.CPP/src/controls/fallback_node.cpp", + "BehaviorTree.CPP/src/controls/parallel_node.cpp", + "BehaviorTree.CPP/src/controls/reactive_sequence.cpp", + "BehaviorTree.CPP/src/controls/reactive_fallback.cpp", + "BehaviorTree.CPP/src/controls/sequence_node.cpp", + "BehaviorTree.CPP/src/controls/sequence_star_node.cpp", + "BehaviorTree.CPP/src/controls/switch_node.cpp", + "BehaviorTree.CPP/src/controls/while_do_else_node.cpp", + "BehaviorTree.CPP/src/loggers/bt_cout_logger.cpp", + "BehaviorTree.CPP/src/loggers/bt_file_logger.cpp", + "BehaviorTree.CPP/src/loggers/bt_minitrace_logger.cpp", + "BehaviorTree.CPP/src/loggers/bt_observer.cpp", + "BehaviorTree.CPP/3rdparty/tinyxml2/tinyxml2.cpp", + "BehaviorTree.CPP/3rdparty/minitrace/minitrace.cpp", + "BehaviorTree.CPP/src/shared_library_UNIX.cpp", + ] + + defines = [ + "LEXY_HAS_UNICODE_DATABASE=1", + "behaviortree_cpp_EXPORTS", + ] + + configs = [ + ":behaviortreecpp_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:lexy_file", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +config("dummy_nodes_dyn_config"){ + cflags_cc = [ + "-O3", + "-DNDEBUG", + "-fPIC", + "-Wpedantic", + "-std=gnu++17", + "-fexceptions", + "-frtti", + "-Wno-deprecated-volatile", + "-Wno-unused-lambda-capture", + ] + + include_dirs = [ + "BehaviorTree.CPP/include", + "BehaviorTree.CPP/sample_nodes" + ] + +} + +ohos_shared_library("dummy_nodes_dyn") { + + output_name = "dummy_nodes_dyn" + + sources = [ + "BehaviorTree.CPP/sample_nodes/dummy_nodes.cpp", + ] + + defines = [ + "BT_PLUGIN_EXPORT", + "dummy_nodes_dyn_EXPORTS", + ] + + configs = [ + ":dummy_nodes_dyn_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +config("crossdoor_nodes_dyn_config"){ + cflags_cc = [ + + "-O3", + "-DNDEBUG", + "-fPIC", + "-Wpedantic", + "-std=gnu++17", + "-fexceptions", + "-frtti", + "-Wno-deprecated-volatile", + "-Wno-unused-lambda-capture", + ] + + include_dirs = [ + "BehaviorTree.CPP/include", + "BehaviorTree.CPP/sample_nodes" + ] + +} + +ohos_shared_library("crossdoor_nodes_dyn") { + + output_name = "crossdoor_nodes_dyn" + + sources = [ + "BehaviorTree.CPP/sample_nodes/crossdoor_nodes.cpp", + ] + + defines = [ + "BT_PLUGIN_EXPORT", + "crossdoor_nodes_dyn_EXPORTS", + ] + + configs = [ + ":crossdoor_nodes_dyn_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +config("movebase_node_dyn_config"){ + cflags_cc = [ + "-O3", + "-DNDEBUG", + "-fPIC", + "-Wpedantic", + "-std=gnu++17", + "-fexceptions", + "-frtti", + "-Wno-deprecated-volatile", + "-Wno-unused-lambda-capture", + ] + + include_dirs = [ + "BehaviorTree.CPP/include", + "BehaviorTree.CPP/sample_nodes" + ] + +} + +ohos_shared_library("movebase_node_dyn") { + + output_name = "movebase_node_dyn" + + sources = [ + "BehaviorTree.CPP/sample_nodes/movebase_node.cpp", + ] + + defines = [ + "BT_PLUGIN_EXPORT", + "movebase_node_dyn_EXPORTS", + ] + + configs = [ + ":movebase_node_dyn_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +group("tests") { + +if(enable_behaviortree_test){ + deps = [ + ":t01_build_your_first_tree", + ":t02_basic_ports", + ":t03_generic_ports", + ":t05_crossdoor", + ":t04_reactive_sequence", + ":t06_subtree_port_remapping", + ":t07_load_multiple_xml", + ":t08_additional_node_args", + ":t09_scripting", + ":t10_observer", + ":t11_replace_rules", + ":ex01_wrap_legacy", + ":ex02_runtime_ports", + ":ex04_waypoints" + ] +}else { + deps = [] +} +} + +config("executable_public_config"){ + cflags_cc = [ + "-O3", + "-DNDEBUG", + "-Wpedantic", + "-std=gnu++17", + "-fexceptions", + "-frtti", + "-Wno-deprecated-volatile", + "-Wno-unused-lambda-capture", + ] + + include_dirs = [ + "BehaviorTree.CPP/include", + "BehaviorTree.CPP/sample_nodes" + ] + +} + +ohos_executable("t01_build_your_first_tree") { + + output_name = "t01_build_your_first_tree" + + sources = [ + "BehaviorTree.CPP/examples/t01_build_your_first_tree.cpp", + ] + + configs = [ + ":executable_public_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +ohos_executable("t02_basic_ports") { + + output_name = "t02_basic_ports" + + sources = [ + "BehaviorTree.CPP/examples/t02_basic_ports.cpp", + ] + + configs = [ + ":executable_public_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +ohos_executable("t03_generic_ports") { + + output_name = "t03_generic_ports" + + sources = [ + "BehaviorTree.CPP/examples/t03_generic_ports.cpp", + ] + + configs = [ + ":executable_public_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +ohos_executable("t04_reactive_sequence") { + + output_name = "t04_reactive_sequence" + + sources = [ + "BehaviorTree.CPP/examples/t04_reactive_sequence.cpp", + ] + + configs = [ + ":executable_public_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +ohos_executable("t05_crossdoor") { + + output_name = "t05_crossdoor" + + sources = [ + "BehaviorTree.CPP/examples/t05_crossdoor.cpp", + ] + + configs = [ + ":executable_public_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +ohos_executable("t06_subtree_port_remapping") { + + output_name = "t06_subtree_port_remapping" + + sources = [ + "BehaviorTree.CPP/examples/t06_subtree_port_remapping.cpp", + ] + + configs = [ + ":executable_public_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +ohos_executable("t07_load_multiple_xml") { + + output_name = "t07_load_multiple_xml" + + sources = [ + "BehaviorTree.CPP/examples/t07_load_multiple_xml.cpp", + ] + + configs = [ + ":executable_public_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +ohos_executable("t08_additional_node_args") { + + output_name = "t08_additional_node_args" + + sources = [ + "BehaviorTree.CPP/examples/t08_additional_node_args.cpp", + ] + + configs = [ + ":executable_public_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +ohos_executable("t09_scripting") { + + output_name = "t09_scripting" + + sources = [ + "BehaviorTree.CPP/examples/t09_scripting.cpp", + ] + + configs = [ + ":executable_public_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +config("t10_observer_config"){ + cflags_cc = [ + "-O3", + "-DNDEBUG", + "-Wpedantic", + "-std=gnu++17", + "-fexceptions", + "-frtti", + "-Wno-deprecated-volatile", + "-Wno-unused-lambda-capture", + "-Wno-unused-variable", + ] + + include_dirs = [ + "BehaviorTree.CPP/include", + "BehaviorTree.CPP/sample_nodes" + ] + +} + +ohos_executable("t10_observer") { + + output_name = "t10_observer" + + sources = [ + "BehaviorTree.CPP/examples/t10_observer.cpp", + ] + + configs = [ + ":t10_observer_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +ohos_executable("t11_replace_rules") { + + output_name = "t11_replace_rules" + + sources = [ + "BehaviorTree.CPP/examples/t11_replace_rules.cpp", + ] + + configs = [ + ":executable_public_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +ohos_executable("ex01_wrap_legacy") { + + output_name = "ex01_wrap_legacy" + + sources = [ + "BehaviorTree.CPP/examples/ex01_wrap_legacy.cpp", + ] + + configs = [ + ":executable_public_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +ohos_executable("ex02_runtime_ports") { + + output_name = "ex02_runtime_ports" + + sources = [ + "BehaviorTree.CPP/examples/ex02_runtime_ports.cpp", + ] + + configs = [ + ":executable_public_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} + +ohos_executable("ex04_waypoints") { + + output_name = "ex04_waypoints" + + sources = [ + "BehaviorTree.CPP/examples/ex04_waypoints.cpp", + ] + + configs = [ + ":executable_public_config", + ":public_config", + ] + + deps = [ + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:bt_sample_nodes", + ] + + install_enable = true + + install_images = [ + "system", + "ramdisk", + "updater", + ] + + part_name = "behaviortree" +} \ No newline at end of file diff --git a/thirdparty/behaviortree/README.OpenSource b/thirdparty/behaviortree/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..a78e67441feec94575bf1bc66899824e9fd36969 --- /dev/null +++ b/thirdparty/behaviortree/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "behaviortree", + "License": "MIT", + "License File": "LICENSE", + "Version Number": "4.1.1", + "Owner": "jia_jiahao@runkaihong.com.cn", + "Upstream URL": "https://github.com/BehaviorTree/BehaviorTree.CPP", + "Description": "This C++ library provides a framework to create BehaviorTrees. It is designed to be flexible, easy to use and fast." + } +] diff --git a/thirdparty/behaviortree/README_zh.md b/thirdparty/behaviortree/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..941c5ac35cf0aaec1b0dd965a6ce13cc300dee3e --- /dev/null +++ b/thirdparty/behaviortree/README_zh.md @@ -0,0 +1,17 @@ +# behaviortree三方库说明 + +## 功能简介 + +behaviortree提供了一个创建行为树的框架,常用来做任务或状态管理。 + +## 使用约束 + +- ROM版本:OpenHarmony 3.2 Release +- 三方库版本:4.1.1 +- 当前适配的功能:behaviortree行为树任务或状态管理功能 +- [License:MIT](https://github.com/BehaviorTree/BehaviorTree.CPP/blob/4.1.1/LICENSE) + +## 集成方式 + +- [系统rom包集成](./docs/rom_integrate.md) + diff --git a/thirdparty/behaviortree/bundle.json b/thirdparty/behaviortree/bundle.json new file mode 100644 index 0000000000000000000000000000000000000000..2cdd8bbb8daceea0be53b133e12247532ede673f --- /dev/null +++ b/thirdparty/behaviortree/bundle.json @@ -0,0 +1,44 @@ +{ + "name": "@ohos/behaviortree", + "description": "This C++ library provides a framework to create BehaviorTrees. It is designed to be flexible, easy to use and fast.", + "version": "v4.1.1", + "license": "MIT", + "publishAs": "", + "segment": { + "destPath": "third_party/behaviortree" + }, + "dirs": {}, + "scripts": {}, + "readmePath": { + }, + "component": { + "name": "behaviortree", + "subsystem": "thirdparty", + "syscap": [], + "features": [], + "adapted_system_type": ["standard"], + "rom": "", + "ram": "", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": [ + "//third_party/behaviortree:lexy_file", + "//third_party/behaviortree:bt_sample_nodes", + "//third_party/behaviortree:behaviortree_cpp", + "//third_party/behaviortree:dummy_nodes_dyn", + "//third_party/behaviortree:crossdoor_nodes_dyn", + "//third_party/behaviortree:movebase_node_dyn", + "//third_party/behaviortree:tests" + ], + "inner_kits": [], + "test": [] + } + } +} + + + + diff --git a/thirdparty/behaviortree/docs/pic/result.png b/thirdparty/behaviortree/docs/pic/result.png new file mode 100644 index 0000000000000000000000000000000000000000..2a35dbfa249996822b2cbeab52da058abd1742e9 Binary files /dev/null and b/thirdparty/behaviortree/docs/pic/result.png differ diff --git a/thirdparty/behaviortree/docs/rom_integrate.md b/thirdparty/behaviortree/docs/rom_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..716cca668cfa06a89095029509ccd3803e4aa445 --- /dev/null +++ b/thirdparty/behaviortree/docs/rom_integrate.md @@ -0,0 +1,161 @@ +# behaviortree如何集成到系统Rom + +## 准备源码工程 + +本库是基于OpenHarmony-v3.2-Release版本,在润和RK3568开发板上验证的。如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +### 准备系统Rom源码 + +系统源码获取方法请参照:[OpenHarmony源码下载](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Release/zh-cn/release-notes/OpenHarmony-v3.2-release.md) + +### 增加构建脚本及配置文件 + +- 下载本仓库代码 + + ```sh + cd ~/ + git clone git@gitee.com:openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 仓库代码目录结构说明 + + ``` sh + cd ~/tpc_c_cplusplus/thirdparty/behaviortree/ # 进入到仓库代码库目录 + ``` + + ``` sh + behaviortree + |-- docs ## BehaviorTree集成说明文档目录 + |-- pic ## 存放文档中的图片资源 + |-- BUILD.gn ## Rom版编译构建脚本 + |-- bundle.json ## 组件定义文件 + |-- README.OpenSource ## BehaviorTree 开源信息说明文档 + |-- README_zh.md ## BehaviorTree 说明文档 + ``` + +- 将本仓库behaviortree文件夹拷贝到OpenHarmony的third_party下 + + ``` sh + cp -arf ~/tpc_c_cplusplus/thirdparty/behaviortree ~/OpenHarmony/third_party + ``` + +### 准备三方库源码 + +- 三方库源码下载 + + 将behaviortree-4.1.1源码下载到behaviortree目录。 + + ```shell + cd ~/OpenHarmony/third_party/behaviortree + git clone https://github.com/BehaviorTree/BehaviorTree.CPP.git -b 4.1.1 + ``` + +## 系统Rom中引入三方库 + +- 准备完三方库代码后,我们需要将三方库加入到编译构建体系中。标准系统编译构建可以参考文档[标准系统编译构建指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta1/zh-cn/device-dev/subsystems/subsys-build-standard-large.md)。 +这里我们三方库默认添加到thirdparty子系统中(详细信息参照文档[如何添加一个三方库到OpenHarmony系统中](https://gitee.com/openharmony-sig/knowledge/blob/master/docs/openharmony_getstarted/port_thirdparty/README.md#%E5%8A%A0%E5%85%A5%E7%BC%96%E8%AF%91%E6%9E%84%E5%BB%BA%E4%BD%93%E7%B3%BB))。相关配置已在bundle.json中完成,我们只需要在产品定义中添加BehaviorTree组件即可。 + +- 在产品配置文件中添加BehaviorTree的组件 + 打开//vendor/hihope/rk3568/config.json文件,找到thirdparty子系统并添加BehaviorTree的组件,如果文件中未指定thirdparty子系统,需要手动将子系统信息加上: + + ```json + { + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "behaviortree", + "features": [] + } + ] + } + ``` + + +## 系统Rom中引入三方库测试程序 + +如果需要编译测试用例,在OpenHarmony源码的vendor/hihope/rk3568/config.json文件,对应组件的features中打开编译选项,如下 + ```json + { + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "behaviortree", + "features": ["enable_behaviortree_test=true"] + } + ] + } + ``` + +## 编译工程 + +- 在此选择build.sh脚本编译方式 + ``` + ./build.sh --product-name rk3568 --ccache --build-target=behaviortree --target-cpu arm + ``` + + ``` + 参数释义 + --product-name rk3568 编译rk3568产品 + --target-cpu arm 编译32位系统(未配置默认编译32位) + --target-cpu arm64 编译64位系统 + ``` + +- 正常编译完后会在out/rk3568/thirdparty/behaviortree下生成ex01_wrap_legacy、ex02_runtime_ports、ex04_waypoints、t01_build_your_first_tree、t02_basic_ports、t03_generic_ports、t04_reactive_sequence、t05_crossdoor、t06_subtree_port_remapping、t07_load_multiple_xml、t08_additional_node_args、t09_scripting、t10_observer、t11_replace_rules等14个测试用例。 + +- 在out/rk3568/thirdparty/behaviortree下生成libbehaviortree_cpp.z.so + +## 安装应用程序 +将编译生成的库和测试文件放到板子上运行,为避免每次将文件推入设备都烧录整个镜像,使用hdc工具将文件推到开发板上 。 + +- 通过源码编译生成hdc工具 +``` +# 安装依赖 +./build/build_scripts/env_setup.sh + +# 执行完上述命令后记得执行source ~/.bashrc或者重启终端 +source ~/.bashrc + +# 安装编译SDK需要的依赖包 +sudo apt-get install libxcursor-dev libxrandr-dev libxinerama-dev + +# 选择产品ohos-sdk +./build.sh --product-name ohos-sdk --ccache --build-target ohos_ndk +``` + +- 将工具拷贝到Windows,可以为工具目录配置环境变量,也可以在工具所在目录打开windows命令 + +- 将原生库测试需要的所有文件打包成behaviortree.tar,并拷贝到windows下 + +``` +hdc shell mount -oremount,rw / #修改系统权限为可读写 +hdc file send behaviortree.tar / #将文件包推入开发板 +hdc shell #进入开发板 +tar xvf behaviortree.tar #解压 + #注意需要将库拷贝到/system/lib 或者/system/lib64目录下 +``` + +- 运行测试程序 测试用例非常多,这里演示其中几个用例,如下图 + ![result](pic/result.png) + + + + + +## 运行效果 + +展示三方库在设备上运行的效果,可以贴效果图 + +## 参考资料 +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) +- [如何为三方库组件中添加一个三方库](https://gitee.com/openharmony-sig/knowledge/blob/master/docs/openharmony_getstarted/port_thirdparty/README.md) +- [标准系统编译构建指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta1/zh-cn/device-dev/subsystems/subsys-build-standard-large.md) \ No newline at end of file