Template Class GenericTimer

Inheritance Relationships

Base Type

Derived Type

Class Documentation

template<typename FunctorT, typename std::enable_if<rclcpp::function_traits::same_arguments<FunctorT, VoidCallbackType>::value || rclcpp::function_traits::same_arguments<FunctorT, TimerCallbackType>::value>::type* = nullptr>
class GenericTimer : public rclcpp::TimerBase

Generic timer. Periodically executes a user-specified callback.

Subclassed by rclcpp::WallTimer< FunctorT, >

Public Functions

inline explicit GenericTimer(Clock::SharedPtr clock, std::chrono::nanoseconds period, FunctorT &&callback, rclcpp::Context::SharedPtr context)

Default constructor.

  • clock[in] The clock providing the current time.

  • period[in] The interval at which the timer fires.

  • callback[in] User-specified callback function.

  • context[in] custom context to be used.

inline virtual ~GenericTimer()

Default destructor.

inline virtual bool call() override


std::runtime_error – if it failed to notify timer that callback will occurr

inline virtual void execute_callback() override

template<typename CallbackT = FunctorT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, VoidCallbackType>::value>::type* = nullptr>
inline void execute_callback_delegate()
template<typename CallbackT = FunctorT, typename std::enable_if<rclcpp::function_traits::same_arguments<CallbackT, TimerCallbackType>::value>::type* = nullptr>
inline void execute_callback_delegate()
inline virtual bool is_steady() override

Is the clock steady (i.e. is the time between ticks constant?)


True if the clock used by this timer is steady.

Protected Attributes

FunctorT callback_