forked from tka-andrew/learning_BehaviourTreeCPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorial02.cpp
More file actions
33 lines (23 loc) · 1000 Bytes
/
Copy pathtutorial02.cpp
File metadata and controls
33 lines (23 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "tutorial02_nodes.h"
#include "behaviortree_cpp_v3/bt_factory.h"
int main()
{
std::cout<<"============ Tutorial 02 ============\n";
BT::BehaviorTreeFactory factory;
factory.registerNodeType<T02DummyNodes::SaySomething>("SaySomething");
factory.registerNodeType<T02DummyNodes::ThinkWhatToSay>("ThinkWhatToSay");
// SimpleActionNodes can not define their own method providedPorts().
// We should pass a PortsList explicitly if we want the Action to
// be able to use getInput() or setOutput();
BT::PortsList say_something_ports = { BT::InputPort<std::string>("message") };
factory.registerSimpleAction("SaySomething2", T02DummyNodes::SaySomethingSimple,
say_something_ports );
auto tree = factory.createTreeFromFile("./tutorial02_tree.xml");
tree.tickRoot();
/* Expected output:
Robot says: hello
Robot says: this works too
Robot says: The answer is 42
*/
return 0;
}