gtest_subtree.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
3 #include "../sample_nodes/dummy_nodes.h"
4 
5 using namespace BT;
6 
7 TEST(SubTree, SiblingPorts_Issue_72)
8 {
9 
10 static const char* xml_text = R"(
11 
12 <root main_tree_to_execute = "MainTree" >
13 
14  <BehaviorTree ID="MainTree">
15  <Sequence>
16  <SetBlackboard value="hello" output_key="myParam" />
17  <SubTree ID="mySubtree" param="myParam" />
18  <SetBlackboard value="world" output_key="myParam" />
19  <SubTree ID="mySubtree" param="myParam" />
20  </Sequence>
21  </BehaviorTree>
22 
23  <BehaviorTree ID="mySubtree">
24  <SaySomething ID="AlwaysSuccess" message="{param}" />
25  </BehaviorTree>
26 </root> )";
27 
28  BehaviorTreeFactory factory;
29  factory.registerNodeType<DummyNodes::SaySomething>("SaySomething");
30 
31  Tree tree = factory.createTreeFromText(xml_text);
32 
33  for( auto& bb: tree.blackboard_stack)
34  {
35  bb->debugMessage();
36  std::cout << "-----" << std::endl;
37  }
38 
39  auto ret = tree.root_node->executeTick();
40 
41  ASSERT_EQ(ret, NodeStatus::SUCCESS );
42  ASSERT_EQ(tree.blackboard_stack.size(), 3 );
43 }
void registerNodeType(const std::string &ID)
Definition: bt_factory.h:174
TEST(SubTree, SiblingPorts_Issue_72)
TreeNode * root_node
Definition: bt_factory.h:80
The BehaviorTreeFactory is used to create instances of a TreeNode at run-time.
Definition: bt_factory.h:98
Tree createTreeFromText(const std::string &text, Blackboard::Ptr blackboard=Blackboard::create())
Definition: bt_factory.cpp:170
static const char * xml_text
Struct used to store a tree. If this object goes out of scope, the tree is destroyed.
Definition: bt_factory.h:78
virtual BT::NodeStatus executeTick()
The method that should be used to invoke tick() and setStatus();.
Definition: tree_node.cpp:33


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sat Jun 8 2019 18:04:05