crossdoor_nodes.cpp
Go to the documentation of this file.
1 #include "crossdoor_nodes.h"
2 
3 // This function must be implemented in the .cpp file to create
4 // a plugin that can be loaded at run-time
6 {
8 }
9 
11 {
12  SleepMS(500);
13  bool door_open = self.blackboard()->get<bool>("door_open");
14 
15  return door_open ? NodeStatus::SUCCESS : NodeStatus::FAILURE;
16 }
17 
19 {
20  SleepMS(500);
21  bool door_locked = self.blackboard()->get<bool>("door_locked");
22 
23  return door_locked ? NodeStatus::SUCCESS : NodeStatus::FAILURE;
24 }
25 
27 {
28  SleepMS(2000);
29  self.blackboard()->set("door_locked", false);
30 
31  return NodeStatus::SUCCESS;
32 }
33 
35 {
36  SleepMS(1000);
37  bool door_open = self.blackboard()->get<bool>("door_open");
38 
39  return door_open ? NodeStatus::SUCCESS : NodeStatus::FAILURE;
40 }
41 
43 {
44  SleepMS(1000);
45  return NodeStatus::SUCCESS;
46 }
47 
49 {
50  SleepMS(2000);
51  bool door_locked = self.blackboard()->get<bool>("door_locked");
52 
53  if (door_locked)
54  {
55  return NodeStatus::FAILURE;
56  }
57 
58  self.blackboard()->set("door_open", true);
59  return NodeStatus::SUCCESS;
60 }
61 
63 {
64  bool door_open = self.blackboard()->get<bool>("door_open");
65 
66  if (door_open)
67  {
68  SleepMS(1500);
69  self.blackboard()->set("door_open", false);
70  }
71  return NodeStatus::SUCCESS;
72 }
73 
75 {
76  factory.registerSimpleCondition("IsDoorOpen", IsDoorOpen);
77  factory.registerSimpleAction("PassThroughDoor", PassThroughDoor);
78  factory.registerSimpleAction("PassThroughWindow", PassThroughWindow);
79  factory.registerSimpleAction("OpenDoor", OpenDoor);
80  factory.registerSimpleAction("CloseDoor", CloseDoor);
81  factory.registerSimpleCondition("IsDoorLocked", IsDoorLocked);
82  factory.registerSimpleAction("UnlockDoor", UnlockDoor);
83 }
BT::NodeStatus PassThroughDoor(TreeNode &self)
BT::NodeStatus PassThroughWindow(TreeNode &self)
BT::NodeStatus CloseDoor(TreeNode &self)
void registerSimpleCondition(const std::string &ID, const SimpleConditionNode::TickFunctor &tick_functor)
Register a SimpleConditionNode.
Definition: bt_factory.cpp:74
BT::NodeStatus OpenDoor(TreeNode &self)
void RegisterNodes(BT::BehaviorTreeFactory &factory)
void SleepMS(int ms)
Definition: movebase_node.h:12
BT::NodeStatus IsDoorOpen(TreeNode &self)
void registerSimpleAction(const std::string &ID, const SimpleActionNode::TickFunctor &tick_functor)
Register a SimpleActionNode.
Definition: bt_factory.cpp:85
BT::NodeStatus IsDoorLocked(TreeNode &self)
NodeStatus
Definition: basic_types.h:28
BT::NodeStatus UnlockDoor(TreeNode &self)
BT_REGISTER_NODES(factory)


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