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 
35 #include <tf2/time.h>
36 
37 #include <rclcpp/rclcpp.hpp>
38 
39 #include <mutex>
40 #include <unordered_map>
41 
42 namespace tf2_ros
43 {
44 
51 {
52 public:
55  rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base,
56  rclcpp::node_interfaces::NodeTimersInterface::SharedPtr node_timers);
57 
58  virtual ~CreateTimerROS() = default;
59 
72  rclcpp::Clock::SharedPtr clock,
73  const tf2::Duration & period,
74  TimerCallbackType callback) override;
75 
85  void
86  cancel(const TimerHandle & timer_handle) override;
87 
97  void
98  reset(const TimerHandle & timer_handle) override;
99 
109  void
110  remove(const TimerHandle & timer_handle) override;
111 
112 private:
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_ROS_H_
tf2_ros::CreateTimerROS::reset
TF2_ROS_PUBLIC void reset(const TimerHandle &timer_handle) override
Reset the timer.
tf2_ros::CreateTimerInterface
Abstract interface for creating timers.
Definition: create_timer_interface.h:74
tf2_ros::CreateTimerROS::createTimer
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:48
tf2_ros::CreateTimerROS
Create and manage ROS timers.
Definition: create_timer_ros.h:50
std::function
tf2_ros::CreateTimerROS::cancel
TF2_ROS_PUBLIC void cancel(const TimerHandle &timer_handle) override
Cancel a timer.
tf2_ros::CreateTimerROS::~CreateTimerROS
virtual ~CreateTimerROS()=default
tf2_ros
Definition: async_buffer_interface.h:43
create_timer_interface.h
TF2_ROS_PUBLIC
#define TF2_ROS_PUBLIC
Definition: visibility_control.h:58
visibility_control.h
std::mutex
tf2_ros::CreateTimerROS::remove
TF2_ROS_PUBLIC void remove(const TimerHandle &timer_handle) override
Remove a timer.
std::unordered_map< TimerHandle, rclcpp::TimerBase::SharedPtr >