File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ CompileExample("t11_replace_rules")
30
30
31
31
if (BTCPP_GROOT_INTERFACE AND BTCPP_SQLITE_LOGGING )
32
32
CompileExample ("t12_groot_howto" )
33
+ CompileExample ("generate_log" )
33
34
endif ()
34
35
35
36
CompileExample ("ex01_wrap_legacy" )
Original file line number Diff line number Diff line change
1
+ #include " behaviortree_cpp/bt_factory.h"
2
+ #include " behaviortree_cpp/loggers/groot2_publisher.h"
3
+ #include " behaviortree_cpp/loggers/bt_file_logger_v2.h"
4
+ #include " behaviortree_cpp/loggers/bt_sqlite_logger.h"
5
+
6
+ // clang-format on
7
+
8
+ int main (int argc, char ** argv)
9
+ {
10
+ if (argc < 2 || argc > 3 ) {
11
+ std::cout << " Provide a XML file as first argument. "
12
+ " Second argument might be the name of the tree to instantiate." << std::endl;
13
+ return 1 ;
14
+ }
15
+ const std::string file = argv[1 ];
16
+
17
+ BT::BehaviorTreeFactory factory;
18
+
19
+ BT::Tree tree;
20
+
21
+ if (argc == 3 ) {
22
+ factory.registerBehaviorTreeFromFile (file);
23
+ tree = factory.createTree (argv[2 ]);
24
+ }
25
+ else {
26
+ tree = factory.createTreeFromFile (file);
27
+ }
28
+
29
+ BT::Groot2Publisher publisher (tree);
30
+ BT::FileLogger2 file_logger (tree, " ./generated_log.btlog" );
31
+ BT::SqliteLogger sqlite_logger (tree, " ./generated_log.db3" );
32
+
33
+ // helper function to print the tree
34
+ BT::printTreeRecursively (tree.rootNode ());
35
+
36
+ std::cout << " \n Tree will run indefinitively. Press CTRL-C to stop\n " ;
37
+
38
+ while (true ) {
39
+ tree.tickWhileRunning ();
40
+ }
41
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <root BTCPP_format =" 4" >
3
+ <BehaviorTree ID =" Main" >
4
+ <Sequence >
5
+ <SubTree ID =" Subtree" name =" FirstSubtree" />
6
+ <SubTree ID =" Subtree" name =" SecondSubtree" />
7
+ </Sequence >
8
+ </BehaviorTree >
9
+ <BehaviorTree ID =" Subtree" >
10
+ <Sequence name =" SleepSequence" >
11
+ <Sleep msec =" 300" />
12
+ <AlwaysSuccess />
13
+ </Sequence >
14
+ </BehaviorTree >
15
+ <!-- Description of Node Models (used by Groot) -->
16
+ <TreeNodesModel >
17
+ <Action ID =" Sleep" editable =" true" >
18
+ <input_port name =" msec" />
19
+ </Action >
20
+ </TreeNodesModel >
21
+ </root >
You can’t perform that action at this time.
0 commit comments