dummy_nodes.h
Go to the documentation of this file.
1 #ifndef SIMPLE_BT_NODES_H
2 #define SIMPLE_BT_NODES_H
3 
6 
7 namespace DummyNodes
8 {
10 
12 
14 
16 {
17  public:
19  {
20  }
21 
23 
25 
26  private:
27  bool _opened;
28 };
29 
30 //--------------------------------------
31 
32 // Example of custom SyncActionNode (synchronous action)
33 // without NodeParameters.
35 {
36  public:
37  ApproachObject(const std::string& name) : BT::SyncActionNode(name)
38  {
39  }
40 
41  // You must override the virtual function tick()
42  BT::NodeStatus tick() override;
43 };
44 
45 // Example of custom SyncActionNode (synchronous action)
46 // with NodeParameters.
48 {
49  public:
50  SaySomething(const std::string& name, const BT::NodeParameters& params)
51  : BT::SyncActionNode(name, params)
52  {
53  }
54 
55  // You must override the virtual function tick()
56  BT::NodeStatus tick() override;
57 
58  // It is mandatory to define this static method.
59  // If you don't, BehaviorTreeFactory::registerNodeType will not compile.
61  {
62  static BT::NodeParameters params = {{"message", ""}};
63  return params;
64  }
65 };
66 
68 {
69  static GripperInterface gi;
70  factory.registerSimpleAction("SayHello", std::bind(SayHello));
71  factory.registerSimpleCondition("CheckBattery", std::bind(CheckBattery));
72  factory.registerSimpleCondition("CheckTemperature", std::bind(CheckTemperature));
73  factory.registerSimpleAction("OpenGripper", std::bind(&GripperInterface::open, &gi));
74  factory.registerSimpleAction("CloseGripper", std::bind(&GripperInterface::close, &gi));
75  factory.registerNodeType<ApproachObject>("ApproachObject");
76  factory.registerNodeType<SaySomething>("SaySomething");
77 }
78 }
79 
80 #endif // SIMPLE_BT_NODES_H
void registerNodeType(const std::string &ID)
Definition: bt_factory.h:98
SaySomething(const std::string &name, const BT::NodeParameters &params)
Definition: dummy_nodes.h:50
BT::NodeStatus SayHello()
Definition: dummy_nodes.cpp:12
void registerSimpleCondition(const std::string &ID, const SimpleConditionNode::TickFunctor &tick_functor)
Register a SimpleConditionNode.
Definition: bt_factory.cpp:74
void RegisterNodes(BT::BehaviorTreeFactory &factory)
Definition: dummy_nodes.h:67
The SyncActionNode is an helper derived class that explicitly forbids the status RUNNING and doesn&#39;t ...
Definition: action_node.h:50
std::unordered_map< std::string, std::string > NodeParameters
Definition: tree_node.h:33
BT::NodeStatus CheckTemperature()
Definition: dummy_nodes.cpp:24
void registerSimpleAction(const std::string &ID, const SimpleActionNode::TickFunctor &tick_functor)
Register a SimpleActionNode.
Definition: bt_factory.cpp:85
ApproachObject(const std::string &name)
Definition: dummy_nodes.h:37
static const BT::NodeParameters & requiredNodeParameters()
Definition: dummy_nodes.h:60
NodeStatus
Definition: basic_types.h:28
BT::NodeStatus CheckBattery()
Definition: dummy_nodes.cpp:18


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sat Feb 2 2019 04:01:53