Go to the documentation of this file.00001 #include <gtest/gtest.h>
00002 #include "behaviortree_cpp/bt_factory.h"
00003 #include "../sample_nodes/dummy_nodes.h"
00004
00005 using namespace BT;
00006
00007 TEST(SubTree, SiblingPorts_Issue_72)
00008 {
00009
00010 static const char* xml_text = R"(
00011
00012 <root main_tree_to_execute = "MainTree" >
00013
00014 <BehaviorTree ID="MainTree">
00015 <Sequence>
00016 <SetBlackboard value="hello" output_key="myParam" />
00017 <SubTree ID="mySubtree" param="myParam" />
00018 <SetBlackboard value="world" output_key="myParam" />
00019 <SubTree ID="mySubtree" param="myParam" />
00020 </Sequence>
00021 </BehaviorTree>
00022
00023 <BehaviorTree ID="mySubtree">
00024 <SaySomething ID="AlwaysSuccess" message="{param}" />
00025 </BehaviorTree>
00026 </root> )";
00027
00028 BehaviorTreeFactory factory;
00029 factory.registerNodeType<DummyNodes::SaySomething>("SaySomething");
00030
00031 Tree tree = factory.createTreeFromText(xml_text);
00032
00033 for( auto& bb: tree.blackboard_stack)
00034 {
00035 bb->debugMessage();
00036 std::cout << "-----" << std::endl;
00037 }
00038
00039 auto ret = tree.root_node->executeTick();
00040
00041 ASSERT_EQ(ret, NodeStatus::SUCCESS );
00042 ASSERT_EQ(tree.blackboard_stack.size(), 3 );
00043 }