Go to the documentation of this file.00001 #include "behaviortree_cpp/bt_factory.h"
00002
00003
00004
00005 #ifdef MANUAL_STATIC_LINKING
00006 #include "dummy_nodes.h"
00007 #endif
00008
00009 using namespace BT;
00010
00020
00021 static const char* xml_text = R"(
00022
00023 <root main_tree_to_execute = "MainTree" >
00024
00025 <BehaviorTree ID="MainTree">
00026 <Sequence name="root_sequence">
00027 <ApproachObject name="approach"/>
00028 <CheckBattery name="battery_ok"/>
00029 <OpenGripper name="open_gripper"/>
00030 <ApproachObject name="approach_object"/>
00031 <CloseGripper name="close_gripper"/>
00032 </Sequence>
00033 </BehaviorTree>
00034
00035 </root>
00036 )";
00037
00038
00039
00040 int main()
00041 {
00042
00043 BehaviorTreeFactory factory;
00044
00045
00046
00047
00048
00049
00050 #ifdef MANUAL_STATIC_LINKING
00051
00052
00053
00054 using namespace DummyNodes;
00055
00056
00057
00058
00059 factory.registerNodeType<ApproachObject>("ApproachObject");
00060
00061
00062
00063 factory.registerSimpleCondition("CheckBattery", std::bind(CheckBattery));
00064
00065
00066 GripperInterface gripper;
00067 factory.registerSimpleAction("OpenGripper", std::bind(&GripperInterface::open, &gripper));
00068 factory.registerSimpleAction("CloseGripper", std::bind(&GripperInterface::close, &gripper));
00069
00070 #else
00071
00072
00073 factory.registerFromPlugin("./libdummy_nodes_dyn.so");
00074 #endif
00075
00076
00077
00078
00079 auto tree = factory.createTreeFromText(xml_text);
00080
00081
00082
00083
00084
00085 tree.root_node->executeTick();
00086
00087 return 0;
00088 }
00089
00090
00091
00092
00093
00094
00095
00096