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


behaviortree_cpp_v3
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Wed Jun 26 2024 02:51:19