Template Function rclcpp::create_timer(rclcpp::Clock::SharedPtr, std::chrono::duration<DurationRepT, DurationT>, CallbackT, rclcpp::CallbackGroup::SharedPtr, node_interfaces::NodeBaseInterface *, node_interfaces::NodeTimersInterface *)

Function Documentation

template<typename DurationRepT, typename DurationT, typename CallbackT>
rclcpp::GenericTimer<CallbackT>::SharedPtr rclcpp::create_timer(rclcpp::Clock::SharedPtr clock, std::chrono::duration<DurationRepT, DurationT> period, CallbackT callback, rclcpp::CallbackGroup::SharedPtr group, node_interfaces::NodeBaseInterface *node_base, node_interfaces::NodeTimersInterface *node_timers)

Convenience method to create a general timer with node resources.

Template Parameters:
  • DurationRepT

  • DurationT

  • CallbackT

Parameters:
  • clock – clock to be used

  • period – period to execute callback. This duration must be 0 <= period < nanoseconds::max()

  • callback – callback to execute via the timer period

  • group – callback group

  • node_base – node base interface

  • node_timers – node timer interface

Throws:

std::invalid_argument – if either clock, node_base or node_timers are nullptr, or period is negative or too large

Returns:

shared pointer to a generic timer