1
1
#include " behavior_tree_core/xml_parsing.h"
2
- #include " behavior_tree_logger/bt_cout_logger.h"
3
- #include " behavior_tree_logger/bt_file_logger.h"
4
2
5
3
#include " dummy_nodes.h"
6
4
#include " movebase_node.h"
@@ -26,7 +24,9 @@ const std::string xml_text_sequence = R"(
26
24
<Sequence name="root">
27
25
<BatteryOK/>
28
26
<TemperatureOK />
27
+ <SaySomething message="mission started..." />
29
28
<MoveBase goal="1;2;3"/>
29
+ <SaySomething message="mission completed!" />
30
30
</Sequence>
31
31
</BehaviorTree>
32
32
@@ -39,9 +39,11 @@ const std::string xml_text_sequence_star = R"(
39
39
40
40
<BehaviorTree ID="MainTree">
41
41
<SequenceStar name="root">
42
- <BatteryOK/>
43
- <TemperatureOK />
44
- <MoveBase goal="1;2;3"/>
42
+ <BatteryOK/>
43
+ <TemperatureOK />
44
+ <SaySomething message="mission started..." />
45
+ <MoveBase goal="1;2;3"/>
46
+ <SaySomething message="mission completed!" />
45
47
</SequenceStar>
46
48
</BehaviorTree>
47
49
@@ -57,10 +59,13 @@ void Assert(bool condition)
57
59
58
60
int main ()
59
61
{
62
+ using namespace DummyNodes ;
63
+
60
64
BehaviorTreeFactory factory;
61
- factory.registerSimpleCondition (" TemperatureOK" , std::bind ( DummyNodes:: CheckBattery ));
62
- factory.registerSimpleCondition (" BatteryOK" , std::bind ( DummyNodes:: CheckTemperature ));
65
+ factory.registerSimpleCondition (" TemperatureOK" , std::bind ( CheckBattery ));
66
+ factory.registerSimpleCondition (" BatteryOK" , std::bind ( CheckTemperature ));
63
67
factory.registerNodeType <MoveBaseAction>(" MoveBase" );
68
+ factory.registerNodeType <SaySomething>(" SaySomething" );
64
69
65
70
// Compare the state transitions and messages using either
66
71
// xml_text_sequence and xml_text_sequence_star
@@ -75,15 +80,6 @@ int main()
75
80
76
81
auto tree = buildTreeFromText (factory, xml_text);
77
82
78
- // This logger will show all the state transitions on console
79
- StdCoutLogger logger_cout (tree.root_node );
80
- logger_cout.enableTransitionToIdle (false );// make the log less verbose
81
- logger_cout.seTimestampType ( TimestampType::RELATIVE );
82
-
83
- // FileLogger will save the state transitions in a custom file format
84
- // simple_trace.fbl, that can be visualized using the command line tool [bt_log_cat]
85
- FileLogger logger_file (tree.root_node , " simple_trace.fbl" );
86
-
87
83
NodeStatus status;
88
84
89
85
std::cout << " \n --- 1st executeTick() ---" << std::endl;
@@ -111,43 +107,35 @@ int main()
111
107
------------ BUILDING A NEW TREE ------------
112
108
113
109
--- 1st executeTick() ---
114
- [0.000]: root IDLE -> RUNNING
115
110
[ Temperature: OK ]
116
- [0.000]: BatteryOK IDLE -> SUCCESS
117
111
[ Battery: OK ]
118
- [0.000]: TemperatureOK IDLE -> SUCCESS
119
- [0.000]: MoveBase IDLE -> RUNNING
112
+ Robot says: "mission started..."
120
113
[ MoveBase: STARTED ]. goal: x=1 y=2.0 theta=3.00
121
114
122
115
--- 2nd executeTick() ---
123
116
[ Temperature: OK ]
124
117
[ Battery: OK ]
125
118
[ MoveBase: FINISHED ]
126
- [0.253]: MoveBase RUNNING -> SUCCESS
127
119
128
120
--- 3rd executeTick() ---
129
121
[ Temperature: OK ]
130
122
[ Battery: OK ]
131
- [0.301]: root RUNNING -> SUCCESS
123
+ Robot says: "mission completed!"
132
124
133
125
134
126
------------ BUILDING A NEW TREE ------------
135
127
136
128
--- 1st executeTick() ---
137
- [0.000]: root IDLE -> RUNNING
138
129
[ Temperature: OK ]
139
- [0.000]: BatteryOK IDLE -> SUCCESS
140
130
[ Battery: OK ]
141
- [0.000]: TemperatureOK IDLE -> SUCCESS
142
- [0.000]: MoveBase IDLE -> RUNNING
131
+ Robot says: "mission started..."
143
132
[ MoveBase: STARTED ]. goal: x=1 y=2.0 theta=3.00
144
133
145
134
--- 2nd executeTick() ---
146
135
[ MoveBase: FINISHED ]
147
- [0.254]: MoveBase RUNNING -> SUCCESS
148
136
149
137
--- 3rd executeTick() ---
150
- [0.301]: root RUNNING -> SUCCESS
138
+ Robot says: "mission completed!"
151
139
152
140
*/
153
141
0 commit comments