rclcpp
master
C++ ROS Client Library API
|
Go to the documentation of this file.
15 #ifndef RCLCPP__TIMER_HPP_
16 #define RCLCPP__TIMER_HPP_
24 #include <type_traits>
34 #include "tracetools/tracetools.h"
35 #include "tracetools/utils.hpp"
37 #include "rcl/error_handling.h"
59 Clock::SharedPtr clock,
61 rclcpp::Context::SharedPtr context);
178 rclcpp_timer_callback_added,
182 rclcpp_callback_register,
208 TRACEPOINT(callback_start,
static_cast<const void *
>(&
callback_),
false);
209 execute_callback_delegate<>();
210 TRACEPOINT(callback_end,
static_cast<const void *
>(&
callback_));
215 typename CallbackT = FunctorT,
227 typename CallbackT = FunctorT,
254 typename
std::enable_if<
272 FunctorT && callback,
275 std::make_shared<
Clock>(RCL_STEADY_TIME), period,
std::move(callback), context)
284 #endif // RCLCPP__TIMER_HPP_
std::shared_ptr< const rcl_timer_t > get_timer_handle()
virtual bool is_steady()=0
Is the clock steady (i.e. is the time between ticks constant?)
std::atomic< bool > in_use_by_wait_set_
Definition: timer.hpp:144
#define RCLCPP_DISABLE_COPY(...)
Definition: macros.hpp:26
TimerBase(Clock::SharedPtr clock, std::chrono::nanoseconds period, rclcpp::Context::SharedPtr context)
TimerBase constructor.
virtual void execute_callback()=0
Call the callback function when the timer signal is emitted.
rcl_ret_t rcl_timer_call(rcl_timer_t *timer)
void cancel()
Cancel the timer.
Clock::SharedPtr clock_
Definition: timer.hpp:141
Generic timer. Periodically executes a user-specified callback.
Definition: timer.hpp:159
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
#define RCLCPP_SMART_PTR_DEFINITIONS(...)
Definition: macros.hpp:36
bool is_ready()
Check if the timer is ready to trigger the callback.
void execute_callback_delegate()
Definition: timer.hpp:221
bool is_canceled()
Return the timer cancellation state.
virtual ~GenericTimer()
Default destructor.
Definition: timer.hpp:188
FunctorT callback_
Definition: timer.hpp:249
Definition: function_traits.hpp:159
std::chrono::nanoseconds time_until_trigger()
Check how long the timer has until its next scheduled callback.
Context which encapsulates shared state between nodes and other similar entities.
Definition: context.hpp:68
std::shared_ptr< rcl_timer_t > timer_handle_
Definition: timer.hpp:142
bool exchange_in_use_by_wait_set_state(bool in_use_state)
Exchange the "in use by wait set" state for this timer.
void reset()
Reset the timer.
virtual ~TimerBase()
TimerBase destructor.
void execute_callback() override
Definition: timer.hpp:199
Definition: timer.hpp:259
#define RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(...)
Definition: macros.hpp:51
bool is_steady() override
Is the clock steady (i.e. is the time between ticks constant?)
Definition: timer.hpp:241
#define RCL_RET_TIMER_CANCELED