rclcpp
master
C++ ROS Client Library API
|
Go to the documentation of this file.
15 #ifndef RCLCPP__CREATE_TIMER_HPP_
16 #define RCLCPP__CREATE_TIMER_HPP_
34 template<
typename CallbackT>
35 typename rclcpp::TimerBase::SharedPtr
39 rclcpp::Clock::SharedPtr clock,
41 CallbackT && callback,
42 rclcpp::CallbackGroup::SharedPtr group =
nullptr)
47 std::forward<CallbackT>(callback),
48 node_base->get_context());
50 node_timers->add_timer(timer, group);
55 template<
typename NodeT,
typename CallbackT>
56 typename rclcpp::TimerBase::SharedPtr
59 rclcpp::Clock::SharedPtr clock,
61 CallbackT && callback,
62 rclcpp::CallbackGroup::SharedPtr group =
nullptr)
69 std::forward<CallbackT>(callback),
88 template<
typename DurationRepT,
typename DurationT,
typename CallbackT>
93 rclcpp::CallbackGroup::SharedPtr group,
97 if (node_base ==
nullptr) {
101 if (node_timers ==
nullptr) {
106 std::chrono::duration_cast<std::chrono::nanoseconds>(period),
115 #endif // RCLCPP__CREATE_TIMER_HPP_
rclcpp::WallTimer< CallbackT >::SharedPtr create_wall_timer(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 timer with node resources.
Definition: create_timer.hpp:90
virtual rclcpp::Context::SharedPtr get_context()=0
Return the context of the node.
std::shared_ptr< rclcpp::node_interfaces::NodeBaseInterface > get_node_base_interface(NodeType &&node)
Get the NodeBaseInterface as a shared pointer from a pointer to a "Node like" object.
Definition: get_node_base_interface.hpp:72
DurationT to_chrono() const
Convert Duration into a std::chrono::Duration.
Definition: duration.hpp:135
virtual void add_timer(rclcpp::TimerBase::SharedPtr timer, rclcpp::CallbackGroup::SharedPtr callback_group)=0
Add a timer to the node.
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
Pure virtual interface class for the NodeBase part of the Node API.
Definition: node_base_interface.hpp:36
Pure virtual interface class for the NodeTimers part of the Node API.
Definition: node_timers_interface.hpp:29
Definition: duration.hpp:26
rclcpp::TimerBase::SharedPtr create_timer(std::shared_ptr< node_interfaces::NodeBaseInterface > node_base, std::shared_ptr< node_interfaces::NodeTimersInterface > node_timers, rclcpp::Clock::SharedPtr clock, rclcpp::Duration period, CallbackT &&callback, rclcpp::CallbackGroup::SharedPtr group=nullptr)
Definition: create_timer.hpp:36
Definition: timer.hpp:259
std::shared_ptr< rclcpp::node_interfaces::NodeTimersInterface > get_node_timers_interface(NodeType &&node)
Get the NodeTimersInterface as a shared pointer from a pointer to a "Node like" object.
Definition: get_node_timers_interface.hpp:72