1
1
#include " behaviortree_cpp/bt_factory.h"
2
- #include " behaviortree_cpp/decorators/loop_node.h"
3
2
#include " behaviortree_cpp/loggers/bt_cout_logger.h"
4
- #include < list>
5
3
6
4
using namespace BT ;
7
5
@@ -14,15 +12,15 @@ using namespace BT;
14
12
* We are telling to the factory that the callee should remap
15
13
* two mandatory inputs, called:
16
14
*
17
- * - in_value (that has the default value 42)
18
- * - in_name (no default)
15
+ * - sub_in_value (that has the default value 42)
16
+ * - sub_in_name (no default)
19
17
*
20
18
* Similarly, there are two output values:
21
19
*
22
- * - out_value (default remapping to port {output})
23
- * - out_state (no default)
20
+ * - sub_out_result (default remapping to port {output})
21
+ * - sub_out_state (no default)
24
22
*
25
- * The callee MUST specify, at least, those remapping that have
23
+ * The callee MUST specify those remapping that have
26
24
* no default value.
27
25
*/
28
26
@@ -32,17 +30,17 @@ static const char* xml_subtree = R"(
32
30
33
31
<TreeNodesModel>
34
32
<SubTree ID="MySub">
35
- <input_port name="in_value " default="42"/>
36
- <input_port name="in_name "/>
37
- <output_port name="out_result " default="{output }"/>
38
- <output_port name="out_state "/>
33
+ <input_port name="sub_in_value " default="42"/>
34
+ <input_port name="sub_in_name "/>
35
+ <output_port name="sub_out_result " default="{out_result }"/>
36
+ <output_port name="sub_out_state "/>
39
37
</SubTree>
40
38
</TreeNodesModel>
41
39
42
40
<BehaviorTree ID="MySub">
43
41
<Sequence>
44
- <ScriptCondition code="in_name=='john' && in_value==42 " />
45
- <Script code="out_result :=69; out_state :='ACTIVE'" />
42
+ <ScriptCondition code="sub_in_value==42 && sub_in_name=='john' " />
43
+ <Script code="sub_out_result :=69; sub_out_state :='ACTIVE'" />
46
44
</Sequence>
47
45
</BehaviorTree>
48
46
</root>
@@ -58,9 +56,10 @@ static const char* xml_maintree = R"(
58
56
59
57
<BehaviorTree ID="MainTree">
60
58
<Sequence>
61
- <Script code="name_arg:= 'john' "/>
62
- <SubTree ID="MySub" in_name="{name_arg}" out_state="{state}"/>
63
- <ScriptCondition code=" output==69 && state=='ACTIVE' " />
59
+ <Script code="in_name:= 'john' "/>
60
+ <SubTree ID="MySub" sub_in_name="{in_name}"
61
+ sub_out_state="{out_state}"/>
62
+ <ScriptCondition code=" out_result==69 && out_state=='ACTIVE' " />
64
63
</Sequence>
65
64
</BehaviorTree>
66
65
@@ -83,10 +82,10 @@ int main()
83
82
84
83
// The full remapping was:
85
84
//
86
- // - in_name <-> {name_arg } // specified by callee
87
- // - in_value <-> 42 // default
88
- // - out_result <-> {output } // default
89
- // - out_state <-> {state } // specified by callee
85
+ // - sub_in_name <-> {in_name } // specified by callee 'MainTree'
86
+ // - sub_in_value <-> 42 // default remapping, see model
87
+ // - sub_out_result <-> {out_result } // default remapping, see model
88
+ // - sub_out_state <-> {out_state } // specified by callee 'MainTree'
90
89
91
90
return 0 ;
92
91
}
0 commit comments