From 9bce57233e6d37092112e2d45accf37d9622e0b5 Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Fri, 26 Apr 2024 16:16:29 +0200 Subject: [PATCH] add t19 --- examples/CMakeLists.txt | 1 + examples/t19_global_blackboard.cpp | 111 +++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 examples/t19_global_blackboard.cpp diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 89b562996..407d1b51c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -42,6 +42,7 @@ endif() CompileExample("t17_blackboard_backup") CompileExample("t18_waypoints") +CompileExample("t19_global_blackboard") CompileExample("ex01_wrap_legacy") CompileExample("ex02_runtime_ports") diff --git a/examples/t19_global_blackboard.cpp b/examples/t19_global_blackboard.cpp new file mode 100644 index 000000000..0ab567168 --- /dev/null +++ b/examples/t19_global_blackboard.cpp @@ -0,0 +1,111 @@ +#include "behaviortree_cpp/bt_factory.h" + +using namespace BT; + +/** + * This example introduces the concept of a "global blackboard", + * and the syntax to use it. + * + * As you know know from previous tutorials, blackboard are "scoped", + * i.e. each SubTree (including the one in the root) has its own + * Blackboard, isolated by default, unless we do remapping. + * + * It is possible (since version 4.6) to create a global BB, + * accessible from everywhere without remapping. + * + * In the example below we can access the entry "value" and + * "value_sqr" from everywhere, as long as we use the pregix "@". + * + * Note as doesn't have any remapping + * + * In other words, the prefix "@" means: "search the entry in the top-level + * blackboard of the hierarchy". + * + * In this case, the top-level blackboard will be [global_blackboard]. + */ + +// clang-format off +static const char* xml_main = R"( + + + + + + + + + + + + +