timeout_node.h
Go to the documentation of this file.
00001 #ifndef DECORATOR_TIMEOUT_NODE_H
00002 #define DECORATOR_TIMEOUT_NODE_H
00003 
00004 #include "behaviortree_cpp/decorator_node.h"
00005 #include <atomic>
00006 #include "timer_queue.h"
00007 
00008 namespace BT
00009 {
00023 class TimeoutNode : public DecoratorNode
00024 {
00025   public:
00026     TimeoutNode(const std::string& name, unsigned milliseconds);
00027 
00028     TimeoutNode(const std::string& name, const NodeConfiguration& config);
00029 
00030     ~TimeoutNode() override
00031     {
00032         timer_.cancelAll();
00033     }
00034 
00035     static PortsList providedPorts()
00036     {
00037         return { InputPort<unsigned>("msec", "After a certain amount of time, "
00038                                              "halt() the child if it is still running.") };
00039     }
00040 
00041   private:
00042     TimerQueue timer_ ;
00043 
00044     virtual BT::NodeStatus tick() override;
00045 
00046     std::atomic<bool> child_halted_;
00047     uint64_t timer_id_;
00048 
00049     unsigned msec_;
00050     bool read_parameter_from_ports_;
00051     bool timeout_started_;
00052     std::mutex timeout_mutex_;
00053 };
00054 }
00055 
00056 #endif   // DEADLINE_NODE_H


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sat Jun 8 2019 20:17:15