Functions | Variables
t14_subtree_model.cpp File Reference
#include "behaviortree_cpp/bt_factory.h"
#include "behaviortree_cpp/loggers/bt_cout_logger.h"
Include dependency graph for t14_subtree_model.cpp:

Go to the source code of this file.

Functions

int main ()
 

Variables

static const char * xml_maintree
 
static const char * xml_subtree
 

Function Documentation

◆ main()

int main ( )

Definition at line 68 of file t14_subtree_model.cpp.

Variable Documentation

◆ xml_maintree

const char* xml_maintree
static
Initial value:
= R"(
<root BTCPP_format="4">
<BehaviorTree ID="MainTree">
<Sequence>
<Script code="in_name:= 'john' "/>
<SubTree ID="MySub" sub_in_name="{in_name}"
sub_out_state="{out_state}"/>
<ScriptCondition code=" out_result==69 && out_state=='ACTIVE' " />
</Sequence>
</BehaviorTree>
</root>
)"

Here, when calling "MySub", only sub_in_name and sub_out_state are explicitly remapped. We will use the default values for the other two.

Definition at line 51 of file t14_subtree_model.cpp.

◆ xml_subtree

const char* xml_subtree
static
Initial value:
= R"(
<root BTCPP_format="4">
<TreeNodesModel>
<SubTree ID="MySub">
<input_port name="sub_in_value" default="42"/>
<input_port name="sub_in_name"/>
<output_port name="sub_out_result" default="{out_result}"/>
<output_port name="sub_out_state"/>
</SubTree>
</TreeNodesModel>
<BehaviorTree ID="MySub">
<Sequence>
<ScriptCondition code="sub_in_value==42 && sub_in_name=='john'" />
<Script code="sub_out_result:=69; sub_out_state:='ACTIVE'" />
</Sequence>
</BehaviorTree>
</root>
)"

You can optionally add a model to a SubTrees, in this case, "MySub". We are telling the factory that the callee should remap two mandatory inputs, and two outputs:

  • sub_in_value (that has the default value 42)
  • sub_in_name (no default)
  • sub_out_result (default remapping to port {output})
  • sub_out_state (no default)

The callee (parent tree, including the subtree) MUST specify those remapping which have no default value.

Definition at line 25 of file t14_subtree_model.cpp.



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