timeout_node.h
Go to the documentation of this file.
1 #ifndef DECORATOR_TIMEOUT_NODE_H
2 #define DECORATOR_TIMEOUT_NODE_H
3 
5 #include <atomic>
6 #include "timer_queue.h"
7 
8 namespace BT
9 {
23 class TimeoutNode : public DecoratorNode
24 {
25  public:
26  TimeoutNode(const std::string& name, unsigned milliseconds);
27 
28  TimeoutNode(const std::string& name, const NodeConfiguration& config);
29 
30  ~TimeoutNode() override
31  {
32  timer_.cancelAll();
33  }
34 
36  {
37  return { InputPort<unsigned>("msec", "After a certain amount of time, "
38  "halt() the child if it is still running.") };
39  }
40 
41  private:
43 
44  virtual BT::NodeStatus tick() override;
45 
46  std::atomic<bool> child_halted_;
47  uint64_t timer_id_;
48 
49  unsigned msec_;
53 };
54 }
55 
56 #endif // DEADLINE_NODE_H
size_t cancelAll()
Cancels all timers.
Definition: timer_queue.h:144
TimeoutNode(const std::string &name, unsigned milliseconds)
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:73
bool read_parameter_from_ports_
Definition: timeout_node.h:50
uint64_t timer_id_
Definition: timeout_node.h:47
const NodeConfiguration & config() const
Definition: tree_node.cpp:99
The TimeoutNode will halt() a running child if the latter has been RUNNING for more than a give time...
Definition: timeout_node.h:23
TimerQueue timer_
Definition: timeout_node.h:42
static pthread_mutex_t mutex
Definition: minitrace.cpp:61
static PortsList providedPorts()
Definition: timeout_node.h:35
std::mutex timeout_mutex_
Definition: timeout_node.h:52
std::atomic< bool > child_halted_
Definition: timeout_node.h:46
unsigned msec_
Definition: timeout_node.h:49
~TimeoutNode() override
Definition: timeout_node.h:30
std::unordered_map< std::string, PortInfo > PortsList
Definition: basic_types.h:316
virtual BT::NodeStatus tick() override
Method to be implemented by the user.
NodeStatus
Definition: basic_types.h:35


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sat Jun 8 2019 18:04:05