action_test_node.h
Go to the documentation of this file.
1 #ifndef ACTIONTEST_H
2 #define ACTIONTEST_H
3 
5 
6 namespace BT
7 {
9 {
10 public:
11  SyncActionTest(const std::string& name);
12 
13  BT::NodeStatus tick() override;
14 
15  void setExpectedResult(NodeStatus res);
16 
17  int tickCount() const
18  {
19  return tick_count_;
20  }
21 
22  void resetTicks()
23  {
24  tick_count_ = 0;
25  }
26 
27 private:
30 };
31 
33 {
34 public:
35  AsyncActionTest(const std::string& name,
36  BT::Duration deadline_ms = std::chrono::milliseconds(100));
37 
38  virtual ~AsyncActionTest() override
39  {
40  halt();
41  }
42 
43  // The method that is going to be executed by the thread
44  BT::NodeStatus tick() override;
45 
46  void setTime(BT::Duration time);
47 
48  // The method used to interrupt the execution of the node
49  virtual void halt() override;
50 
51  void setExpectedResult(NodeStatus res);
52 
53  int tickCount() const
54  {
55  return tick_count_;
56  }
57 
58  int successCount() const
59  {
60  return success_count_;
61  }
62 
63  int failureCount() const
64  {
65  return failure_count_;
66  }
67 
69  {
70  success_count_ = 0;
71  failure_count_ = 0;
72  tick_count_ = 0;
73  }
74 
75 private:
76  // using atomic because these variables might be accessed from different threads
78  std::atomic<NodeStatus> expected_result_;
79  std::atomic<int> tick_count_;
82 };
83 } // namespace BT
84 
85 #endif
SyncActionTest(const std::string &name)
virtual void halt() override final
You don&#39;t need to override this.
Definition: action_node.h:62
The AsyncActionNode uses a different thread, where the action will be executed.
Definition: action_node.h:114
void setExpectedResult(NodeStatus res)
The SyncActionNode is an ActionNode that explicitly prevents the status RUNNING and doesn&#39;t require a...
Definition: action_node.h:52
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:101
int failureCount() const
int successCount() const
std::atomic< int > tick_count_
BT::NodeStatus tick() override
Method to be implemented by the user.
NodeStatus expected_result_
NodeStatus
Definition: basic_types.h:35
std::atomic< NodeStatus > expected_result_
std::chrono::high_resolution_clock::duration Duration
Definition: basic_types.h:362
virtual ~AsyncActionTest() override


behaviortree_cpp_v3
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Mon Jul 3 2023 02:50:14