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 {
9 
11 
13 {
14  public:
16  {
17  }
18 
20 
22 
23  private:
24  bool _opened;
25 };
26 
27 //--------------------------------------
28 
29 // Example of custom SyncActionNode (synchronous action)
30 // without ports.
32 {
33  public:
34  ApproachObject(const std::string& name) :
35  BT::SyncActionNode(name, {})
36  {
37  }
38 
39  // You must override the virtual function tick()
40  BT::NodeStatus tick() override;
41 };
42 
43 // Example of custom SyncActionNode (synchronous action)
44 // with an input port.
46 {
47  public:
48  SaySomething(const std::string& name, const BT::NodeConfiguration& config)
49  : BT::SyncActionNode(name, config)
50  {
51  }
52 
53  // You must override the virtual function tick()
54  BT::NodeStatus tick() override;
55 
56  // It is mandatory to define this static method.
58  {
59  return{ BT::InputPort<std::string>("message") };
60  }
61 };
62 
63 //Same as class SaySomething, but to be registered with SimpleActionNode
65 
66 
68 {
69  static GripperInterface grip_singleton;
70 
71  factory.registerSimpleCondition("CheckBattery", std::bind(CheckBattery));
72  factory.registerSimpleAction("OpenGripper", std::bind(&GripperInterface::open, &grip_singleton));
73  factory.registerSimpleAction("CloseGripper", std::bind(&GripperInterface::close, &grip_singleton));
74  factory.registerNodeType<ApproachObject>("ApproachObject");
75  factory.registerNodeType<SaySomething>("SaySomething");
76 }
77 
78 } // end namespace
79 
80 #endif // SIMPLE_BT_NODES_H
void registerNodeType(const std::string &ID)
Definition: bt_factory.h:174
static BT::PortsList providedPorts()
Definition: dummy_nodes.h:57
void RegisterNodes(BT::BehaviorTreeFactory &factory)
Definition: dummy_nodes.h:67
The SyncActionNode is an ActionNode that explicitly prevents the status RUNNING and doesn&#39;t require a...
Definition: action_node.h:52
The BehaviorTreeFactory is used to create instances of a TreeNode at run-time.
Definition: bt_factory.h:98
ApproachObject(const std::string &name)
Definition: dummy_nodes.h:34
void registerSimpleAction(const std::string &ID, const SimpleActionNode::TickFunctor &tick_functor, PortsList ports={})
registerSimpleAction help you register nodes of type SimpleActionNode.
Definition: bt_factory.cpp:92
Abstract base class for Behavior Tree Nodes.
Definition: tree_node.h:53
std::unordered_map< std::string, PortInfo > PortsList
Definition: basic_types.h:316
BT::NodeStatus SaySomethingSimple(BT::TreeNode &self)
Definition: dummy_nodes.cpp:51
NodeStatus
Definition: basic_types.h:35
void registerSimpleCondition(const std::string &ID, const SimpleConditionNode::TickFunctor &tick_functor, PortsList ports={})
registerSimpleCondition help you register nodes of type SimpleConditionNode.
Definition: bt_factory.cpp:80
SaySomething(const std::string &name, const BT::NodeConfiguration &config)
Definition: dummy_nodes.h:48
BT::NodeStatus CheckBattery()
Definition: dummy_nodes.cpp:13


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