diff --git a/rclcpp/include/rclcpp/timer.hpp b/rclcpp/include/rclcpp/timer.hpp index 1e15be7..73c1d74 100644 --- a/rclcpp/include/rclcpp/timer.hpp +++ b/rclcpp/include/rclcpp/timer.hpp @@ -55,6 +55,10 @@ public: void cancel(); + RCLCPP_PUBLIC + void + reset(); + RCLCPP_PUBLIC virtual void execute_callback() = 0; diff --git a/rclcpp/src/rclcpp/timer.cpp b/rclcpp/src/rclcpp/timer.cpp index 1128bbf..e15d683 100644 --- a/rclcpp/src/rclcpp/timer.cpp +++ b/rclcpp/src/rclcpp/timer.cpp @@ -40,6 +40,14 @@ TimerBase::cancel() } } +void +TimerBase::reset() +{ + if (rcl_timer_reset(&timer_handle_) != RCL_RET_OK) { + throw std::runtime_error(std::string("Couldn't reset timer: ") + rcl_get_error_string_safe()); + } +} + bool TimerBase::is_ready() {