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
BT
Definition: ex01_wrap_legacy.cpp:29
BT::AsyncActionTest::tick_count_
std::atomic< int > tick_count_
Definition: action_test_node.h:79
BT::SyncActionTest::tickCount
int tickCount() const
Definition: action_test_node.h:17
BT::AsyncActionTest::resetCounters
void resetCounters()
Definition: action_test_node.h:68
BT::AsyncActionTest::~AsyncActionTest
virtual ~AsyncActionTest() override
Definition: action_test_node.h:38
BT::AsyncActionTest::failure_count_
int failure_count_
Definition: action_test_node.h:81
BT::AsyncActionTest::successCount
int successCount() const
Definition: action_test_node.h:58
BT::AsyncActionTest
Definition: action_test_node.h:32
BT::SyncActionTest::SyncActionTest
SyncActionTest(const std::string &name)
Definition: action_test_node.cpp:74
BT::Duration
std::chrono::high_resolution_clock::duration Duration
Definition: basic_types.h:628
BT::AsyncActionTest::setExpectedResult
void setExpectedResult(NodeStatus res)
Definition: action_test_node.cpp:67
BT::SyncActionTest
Definition: action_test_node.h:8
BT::AsyncActionTest::tickCount
int tickCount() const
Definition: action_test_node.h:53
action_node.h
BT::SyncActionTest::setExpectedResult
void setExpectedResult(NodeStatus res)
Definition: action_test_node.cpp:86
BT::AsyncActionTest::setTime
void setTime(BT::Duration time)
Definition: action_test_node.cpp:62
BT::SyncActionTest::tick
BT::NodeStatus tick() override
Method to be implemented by the user.
Definition: action_test_node.cpp:80
BT::AsyncActionTest::expected_result_
std::atomic< NodeStatus > expected_result_
Definition: action_test_node.h:78
BT::TreeNode::name
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:296
BT::SyncActionTest::resetTicks
void resetTicks()
Definition: action_test_node.h:22
BT::SyncActionTest::tick_count_
int tick_count_
Definition: action_test_node.h:29
BT::AsyncActionTest::time_
BT::Duration time_
Definition: action_test_node.h:77
BT::AsyncActionTest::AsyncActionTest
AsyncActionTest(const std::string &name, BT::Duration deadline_ms=std::chrono::milliseconds(100))
Definition: action_test_node.cpp:17
BT::ThreadedAction
The ThreadedAction executes the tick in a different thread.
Definition: action_node.h:116
BT::AsyncActionTest::halt
virtual void halt() override
Definition: action_test_node.cpp:56
BT::AsyncActionTest::success_count_
int success_count_
Definition: action_test_node.h:80
BT::SyncActionNode
The SyncActionNode is an ActionNode that explicitly prevents the status RUNNING and doesn't require a...
Definition: action_node.h:52
BT::AsyncActionTest::failureCount
int failureCount() const
Definition: action_test_node.h:63
BT::NodeStatus
NodeStatus
Definition: basic_types.h:33
BT::SyncActionTest::expected_result_
NodeStatus expected_result_
Definition: action_test_node.h:28
BT::AsyncActionTest::tick
BT::NodeStatus tick() override
Method to be implemented by the user.
Definition: action_test_node.cpp:25


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Jun 28 2024 02:20:07