delay_node.h
Go to the documentation of this file.
1 #ifndef DECORATOR_DELAY_NODE_H
2 #define DECORATOR_DELAY_NODE_H
3 
5 #include <atomic>
6 #include "timer_queue.h"
7 
8 namespace BT
9 {
24 class DelayNode : public DecoratorNode
25 {
26  public:
27  DelayNode(const std::string& name, unsigned milliseconds);
28 
29  DelayNode(const std::string& name, const NodeConfiguration& config);
30 
31  ~DelayNode() override
32  {
33  halt();
34  }
35 
37  {
38  return {InputPort<unsigned>("delay_msec", "Tick the child after a few milliseconds")};
39  }
40  void halt() override
41  {
42  delay_started_ = false;
43  timer_.cancelAll();
45  }
46 
47  private:
49  uint64_t timer_id_;
50 
51  virtual BT::NodeStatus tick() override;
52 
56  unsigned msec_;
59 };
60 
61 } // namespace BT
62 
63 #endif // DELAY_NODE_H
bool read_parameter_from_ports_
Definition: delay_node.h:57
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:73
DelayNode(const std::string &name, unsigned milliseconds)
Definition: delay_node.cpp:8
virtual BT::NodeStatus tick() override
Method to be implemented by the user.
Definition: delay_node.cpp:27
const NodeConfiguration & config() const
Definition: tree_node.cpp:99
void halt() override
The method used to interrupt the execution of this node.
Definition: delay_node.h:40
TimerQueue timer_
Definition: delay_node.h:48
bool delay_complete_
Definition: delay_node.h:54
static PortsList providedPorts()
Definition: delay_node.h:36
static pthread_mutex_t mutex
Definition: minitrace.cpp:61
virtual void halt() override
The method used to interrupt the execution of this node.
bool delay_aborted_
Definition: delay_node.h:55
bool delay_started_
Definition: delay_node.h:53
unsigned msec_
Definition: delay_node.h:56
size_t cancelAll()
Cancels all timers.
Definition: timer_queue.h:145
std::unordered_map< std::string, PortInfo > PortsList
Definition: basic_types.h:317
The delay node will introduce a delay of a few milliseconds and then tick the child returning the sta...
Definition: delay_node.h:24
~DelayNode() override
Definition: delay_node.h:31
std::mutex delay_mutex_
Definition: delay_node.h:58
NodeStatus
Definition: basic_types.h:35
uint64_t timer_id_
Definition: delay_node.h:49


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