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 
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 ports.
35 {
36  public:
37  ApproachObject(const std::string& name) :
38  BT::SyncActionNode(name, {})
39  {
40  }
41 
42  // You must override the virtual function tick()
43  BT::NodeStatus tick() override;
44 };
45 
46 // Example of custom SyncActionNode (synchronous action)
47 // with an input port.
49 {
50  public:
51  SaySomething(const std::string& name, const BT::NodeConfiguration& config)
52  : BT::SyncActionNode(name, config)
53  {
54  }
55 
56  // You must override the virtual function tick()
57  BT::NodeStatus tick() override;
58 
59  // It is mandatory to define this static method.
61  {
62  return{ BT::InputPort<std::string>("message") };
63  }
64 };
65 
66 //Same as class SaySomething, but to be registered with SimpleActionNode
68 
69 
71 {
72  static GripperInterface grip_singleton;
73 
74  factory.registerSimpleCondition("CheckBattery", std::bind(CheckBattery));
75  factory.registerSimpleCondition("CheckTemperature", std::bind(CheckTemperature));
76  factory.registerSimpleAction("SayHello", std::bind(SayHello));
77  factory.registerSimpleAction("OpenGripper", std::bind(&GripperInterface::open, &grip_singleton));
78  factory.registerSimpleAction("CloseGripper", std::bind(&GripperInterface::close, &grip_singleton));
79  factory.registerNodeType<ApproachObject>("ApproachObject");
80  factory.registerNodeType<SaySomething>("SaySomething");
81 }
82 
83 } // end namespace
84 
85 #endif // SIMPLE_BT_NODES_H
void registerNodeType(const std::string &ID)
Definition: bt_factory.h:290
static BT::PortsList providedPorts()
Definition: dummy_nodes.h:60
BT::NodeStatus SayHello()
Definition: dummy_nodes.cpp:25
void RegisterNodes(BT::BehaviorTreeFactory &factory)
Definition: dummy_nodes.h:70
The SyncActionNode is an ActionNode that explicitly prevents the status RUNNING and doesn&#39;t require a...
Definition: action_node.h:53
The BehaviorTreeFactory is used to create instances of a TreeNode at run-time.
Definition: bt_factory.h:207
BT::NodeStatus CheckTemperature()
Definition: dummy_nodes.cpp:19
ApproachObject(const std::string &name)
Definition: dummy_nodes.h:37
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:111
Abstract base class for Behavior Tree Nodes.
Definition: tree_node.h:53
std::unordered_map< std::string, PortInfo > PortsList
Definition: basic_types.h:317
BT::NodeStatus SaySomethingSimple(BT::TreeNode &self)
Definition: dummy_nodes.cpp:63
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:99
SaySomething(const std::string &name, const BT::NodeConfiguration &config)
Definition: dummy_nodes.h:51
BT::NodeStatus CheckBattery()
Definition: dummy_nodes.cpp:13


behaviotree_cpp_v3
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Tue May 4 2021 02:56:24