tf2_ros  master
This package contains the ROS bindings for the tf2 library, for both Python and C++.
create_timer_interface.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019, Open Source Robotics Foundation, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef TF2_ROS__CREATE_TIMER_INTERFACE_H_
31 #define TF2_ROS__CREATE_TIMER_INTERFACE_H_
32 
33 #include <tf2/time.h>
34 
36 
37 #include <rclcpp/rclcpp.hpp>
38 
39 #include <functional>
40 #include <memory>
41 #include <stdexcept>
42 #include <string>
43 
44 
45 namespace tf2_ros
46 {
47 
48 using TimerHandle = uint64_t;
50 
52 {
53 public:
55  explicit CreateTimerInterfaceException(const std::string & errorDescription)
56  : std::runtime_error(errorDescription)
57  {
58  }
59 };
60 
62 {
63 public:
65  explicit InvalidTimerHandleException(const std::string & description)
66  : std::runtime_error(description)
67  {
68  }
69 };
70 
75 {
76 public:
80 
82  virtual
83  ~CreateTimerInterface() = default;
84 
95  virtual TimerHandle
97  rclcpp::Clock::SharedPtr clock,
98  const tf2::Duration & period,
99  TimerCallbackType callback) = 0;
100 
110  virtual void
111  cancel(const TimerHandle & timer_handle) = 0;
112 
122  virtual void
123  reset(const TimerHandle & timer_handle) = 0;
124 
134  virtual void
135  remove(const TimerHandle & timer_handle) = 0;
136 }; // class CreateTimerInterface
137 
138 } // namespace tf2_ros
139 
140 #endif // TF2_ROS__CREATE_TIMER_INTERFACE_H_
tf2_ros::CreateTimerInterface
Abstract interface for creating timers.
Definition: create_timer_interface.h:74
tf2_ros::InvalidTimerHandleException
Definition: create_timer_interface.h:61
std::string
std::shared_ptr< CreateTimerInterface >
tf2_ros::TimerHandle
uint64_t TimerHandle
Definition: create_timer_interface.h:48
tf2_ros::CreateTimerInterfaceException::CreateTimerInterfaceException
TF2_ROS_PUBLIC CreateTimerInterfaceException(const std::string &errorDescription)
Definition: create_timer_interface.h:55
tf2_ros::CreateTimerInterface::cancel
virtual TF2_ROS_PUBLIC void cancel(const TimerHandle &timer_handle)=0
Cancel a timer.
tf2_ros::InvalidTimerHandleException::InvalidTimerHandleException
TF2_ROS_PUBLIC InvalidTimerHandleException(const std::string &description)
Definition: create_timer_interface.h:65
std::function
tf2_ros::CreateTimerInterface::~CreateTimerInterface
virtual TF2_ROS_PUBLIC ~CreateTimerInterface()=default
tf2_ros::CreateTimerInterface::reset
virtual TF2_ROS_PUBLIC void reset(const TimerHandle &timer_handle)=0
Reset the timer.
tf2_ros::CreateTimerInterface::remove
virtual TF2_ROS_PUBLIC void remove(const TimerHandle &timer_handle)=0
Remove a timer.
tf2_ros::CreateTimerInterfaceException
Definition: create_timer_interface.h:51
tf2_ros
Definition: async_buffer_interface.h:43
std::runtime_error
TF2_ROS_PUBLIC
#define TF2_ROS_PUBLIC
Definition: visibility_control.h:58
visibility_control.h
std
std::unique_ptr
tf2_ros::CreateTimerInterface::createTimer
virtual TF2_ROS_PUBLIC TimerHandle createTimer(rclcpp::Clock::SharedPtr clock, const tf2::Duration &period, TimerCallbackType callback)=0
Create a new timer.