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 || rclcpp::function_traits::same_arguments<FunctorT, TimerInfoCallbackType>::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, bool autostart = true)

Default constructor.

Parameters:
  • 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.

  • autostart – timer state on initialization

inline virtual ~GenericTimer()

Default destructor.

inline virtual std::shared_ptr<void> call() override

Throws:

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

inline virtual void execute_callback(const std::shared_ptr<void> &data) override

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

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

Returns:

True if the clock used by this timer is steady.

Protected Attributes

FunctorT callback_