Classes | Functions | Variables
t16_global_blackboard.cpp File Reference
#include "behaviortree_cpp/bt_factory.h"
Include dependency graph for t16_global_blackboard.cpp:

Go to the source code of this file.

Classes

class  PrintNumber
 

Functions

int main ()
 

Variables

static const char * xml_main
 

Function Documentation

◆ main()

int main ( )

Definition at line 74 of file t16_global_blackboard.cpp.

Variable Documentation

◆ xml_main

const char* xml_main
static
Initial value:
= R"(
<root BTCPP_format="4">
<BehaviorTree ID="MainTree">
<Sequence>
<PrintNumber name="main_print" val="{@value}" />
<SubTree ID="MySub"/>
</Sequence>
</BehaviorTree>
<BehaviorTree ID="MySub">
<Sequence>
<PrintNumber name="sub_print" val="{@value}" />
<Script code="@value_sqr := @value * @value" />
</Sequence>
</BehaviorTree>
</root>
)"

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 <SubTree ID="MySub"> 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].

Definition at line 28 of file t16_global_blackboard.cpp.



behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Jun 28 2024 02:20:08