tf2_ros  master
This package contains the ROS bindings for the tf2 library, for both Python and C++.
create_timer_ros.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_ROS_H
31 #define TF2_ROS__CREATE_TIMER_ROS_H
32 
33 #include <mutex>
34 #include <unordered_map>
35 
36 #include <rclcpp/rclcpp.hpp>
37 
40 
41 namespace tf2_ros
42 {
43 
50 {
51 public:
54  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base,
55  rclcpp::node_interfaces::NodeTimersInterface::SharedPtr node_timers);
56 
57  virtual ~CreateTimerROS() = default;
58 
69  virtual TimerHandle
71  rclcpp::Clock::SharedPtr clock,
72  const tf2::Duration & period,
73  TimerCallbackType callback) override;
74 
84  virtual void
85  cancel(const TimerHandle & timer_handle) override;
86 
96  virtual void
97  reset(const TimerHandle & timer_handle) override;
98 
108  virtual void
109  remove(const TimerHandle & timer_handle) override;
110 
111 private:
112 
113  void
114  cancelNoLock(const TimerHandle & timer_handle);
115 
116  void
117  timerCallback(
118  const TimerHandle & timer_handle,
119  TimerCallbackType callback);
120 
121  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_;
122  rclcpp::node_interfaces::NodeTimersInterface::SharedPtr node_timers_;
123  TimerHandle next_timer_handle_index_;
125  std::mutex timers_map_mutex_;
126 }; // class CreateTimerROS
127 
128 } // namespace tf2_ros
129 
130 #endif // TF2_ROS__CREATE_TIMER_INTERFACE_H
tf2_ros::CreateTimerROS::remove
virtual TF2_ROS_PUBLIC void remove(const TimerHandle &timer_handle) override
Remove a timer.
tf2_ros::CreateTimerROS::cancel
virtual TF2_ROS_PUBLIC void cancel(const TimerHandle &timer_handle) override
Cancel a timer.
tf2_ros::CreateTimerInterface
Abstract interface for creating timers.
Definition: create_timer_interface.h:70
tf2_ros::CreateTimerROS::createTimer
virtual TF2_ROS_PUBLIC TimerHandle createTimer(rclcpp::Clock::SharedPtr clock, const tf2::Duration &period, TimerCallbackType callback) override
Create a new timer.
tf2_ros::CreateTimerROS::CreateTimerROS
TF2_ROS_PUBLIC CreateTimerROS(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base, rclcpp::node_interfaces::NodeTimersInterface::SharedPtr node_timers)
tf2_ros::TimerHandle
uint64_t TimerHandle
Definition: create_timer_interface.h:44
tf2_ros::CreateTimerROS
Create and manage ROS timers.
Definition: create_timer_ros.h:49
std::function
tf2_ros::CreateTimerROS::reset
virtual TF2_ROS_PUBLIC void reset(const TimerHandle &timer_handle) override
Reset the timer.
tf2_ros::CreateTimerROS::~CreateTimerROS
virtual ~CreateTimerROS()=default
tf2_ros
Definition: async_buffer_interface.h:41
create_timer_interface.h
TF2_ROS_PUBLIC
#define TF2_ROS_PUBLIC
Definition: visibility_control.h:58
visibility_control.h
std::mutex
std::unordered_map< TimerHandle, rclcpp::TimerBase::SharedPtr >