11#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"
42
53#include " dummy_nodes.h"
64#include " movebase_node.h"
@@ -26,7 +24,9 @@ const std::string xml_text_sequence = R"(
2624 <Sequence name="root">
2725 <BatteryOK/>
2826 <TemperatureOK />
27+ <SaySomething message="mission started..." />
2928 <MoveBase goal="1;2;3"/>
29+ <SaySomething message="mission completed!" />
3030 </Sequence>
3131 </BehaviorTree>
3232
@@ -39,9 +39,11 @@ const std::string xml_text_sequence_star = R"(
3939
4040 <BehaviorTree ID="MainTree">
4141 <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!" />
4547 </SequenceStar>
4648 </BehaviorTree>
4749
@@ -57,10 +59,13 @@ void Assert(bool condition)
5759
5860int main ()
5961{
62+ using namespace DummyNodes ;
63+
6064 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 ));
6367 factory.registerNodeType <MoveBaseAction>(" MoveBase" );
68+ factory.registerNodeType <SaySomething>(" SaySomething" );
6469
6570 // Compare the state transitions and messages using either
6671 // xml_text_sequence and xml_text_sequence_star
@@ -75,15 +80,6 @@ int main()
7580
7681 auto tree = buildTreeFromText (factory, xml_text);
7782
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-
8783 NodeStatus status;
8884
8985 std::cout << " \n --- 1st executeTick() ---" << std::endl;
@@ -111,43 +107,35 @@ int main()
111107------------ BUILDING A NEW TREE ------------
112108
113109--- 1st executeTick() ---
114- [0.000]: root IDLE -> RUNNING
115110[ Temperature: OK ]
116- [0.000]: BatteryOK IDLE -> SUCCESS
117111[ Battery: OK ]
118- [0.000]: TemperatureOK IDLE -> SUCCESS
119- [0.000]: MoveBase IDLE -> RUNNING
112+ Robot says: "mission started..."
120113[ MoveBase: STARTED ]. goal: x=1 y=2.0 theta=3.00
121114
122115--- 2nd executeTick() ---
123116[ Temperature: OK ]
124117[ Battery: OK ]
125118[ MoveBase: FINISHED ]
126- [0.253]: MoveBase RUNNING -> SUCCESS
127119
128120--- 3rd executeTick() ---
129121[ Temperature: OK ]
130122[ Battery: OK ]
131- [0.301]: root RUNNING -> SUCCESS
123+ Robot says: "mission completed!"
132124
133125
134126------------ BUILDING A NEW TREE ------------
135127
136128--- 1st executeTick() ---
137- [0.000]: root IDLE -> RUNNING
138129[ Temperature: OK ]
139- [0.000]: BatteryOK IDLE -> SUCCESS
140130[ Battery: OK ]
141- [0.000]: TemperatureOK IDLE -> SUCCESS
142- [0.000]: MoveBase IDLE -> RUNNING
131+ Robot says: "mission started..."
143132[ MoveBase: STARTED ]. goal: x=1 y=2.0 theta=3.00
144133
145134--- 2nd executeTick() ---
146135[ MoveBase: FINISHED ]
147- [0.254]: MoveBase RUNNING -> SUCCESS
148136
149137--- 3rd executeTick() ---
150- [0.301]: root RUNNING -> SUCCESS
138+ Robot says: "mission completed!"
151139
152140*/
153141
0 commit comments