Skip to content

Commit ab5f7ad

Browse files
committed
fix
1 parent 7a8b68a commit ab5f7ad

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ endif()
3535

3636
CompileExample("ex01_wrap_legacy")
3737
CompileExample("ex02_runtime_ports")
38-
CompileExample("ex03_subtree_model")
3938
CompileExample("ex04_waypoints")
39+
CompileExample("ex05_subtree_model")
4040

4141
CompileExample("t13_plugin_executor")
4242

examples/ex03_subtree_model.cpp renamed to examples/ex05_subtree_model.cpp

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include "behaviortree_cpp/bt_factory.h"
2-
#include "behaviortree_cpp/decorators/loop_node.h"
32
#include "behaviortree_cpp/loggers/bt_cout_logger.h"
4-
#include <list>
53

64
using namespace BT;
75

@@ -14,15 +12,15 @@ using namespace BT;
1412
* We are telling to the factory that the callee should remap
1513
* two mandatory inputs, called:
1614
*
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)
1917
*
2018
* Similarly, there are two output values:
2119
*
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)
2422
*
25-
* The callee MUST specify, at least, those remapping that have
23+
* The callee MUST specify those remapping that have
2624
* no default value.
2725
*/
2826

@@ -32,17 +30,17 @@ static const char* xml_subtree = R"(
3230
3331
<TreeNodesModel>
3432
<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"/>
3937
</SubTree>
4038
</TreeNodesModel>
4139
4240
<BehaviorTree ID="MySub">
4341
<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'" />
4644
</Sequence>
4745
</BehaviorTree>
4846
</root>
@@ -58,9 +56,10 @@ static const char* xml_maintree = R"(
5856
5957
<BehaviorTree ID="MainTree">
6058
<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' " />
6463
</Sequence>
6564
</BehaviorTree>
6665
@@ -83,10 +82,10 @@ int main()
8382

8483
// The full remapping was:
8584
//
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'
9089

9190
return 0;
9291
}

0 commit comments

Comments
 (0)