From dd6fad6d4280939d920a708987b38593aaf36538 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Fri, 8 Sep 2023 16:40:09 -0400 Subject: [PATCH] Fix the return type of Rate::period. (#2301) In a recent commit (bc435776a257fcf76c5b0124bec26f6824342e34), we reworked how the Rate class worked so it could be used with ROS time as well. Unfortunately, we also accidentally broke the API of it by changing the return type of Rate::period to a Duration instead of a std::chrono::nanoseconds . Put this back to a std::chrono::nanoseconds; if we want to change it to a Duration, we'll have to add a new method and deprecate this one. Signed-off-by: Chris Lalancette --- rclcpp/include/rclcpp/rate.hpp | 2 +- rclcpp/src/rclcpp/rate.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rclcpp/include/rclcpp/rate.hpp b/rclcpp/include/rclcpp/rate.hpp index 884e462a76..381e8d7908 100644 --- a/rclcpp/include/rclcpp/rate.hpp +++ b/rclcpp/include/rclcpp/rate.hpp @@ -163,7 +163,7 @@ class Rate : public RateBase reset(); RCLCPP_PUBLIC - Duration + std::chrono::nanoseconds period() const; private: diff --git a/rclcpp/src/rclcpp/rate.cpp b/rclcpp/src/rclcpp/rate.cpp index 04a1f57185..9a6e3d486b 100644 --- a/rclcpp/src/rclcpp/rate.cpp +++ b/rclcpp/src/rclcpp/rate.cpp @@ -14,6 +14,7 @@ #include "rclcpp/rate.hpp" +#include #include namespace rclcpp @@ -87,10 +88,10 @@ Rate::reset() last_interval_ = clock_->now(); } -Duration +std::chrono::nanoseconds Rate::period() const { - return period_; + return std::chrono::nanoseconds(period_.nanoseconds()); } WallRate::WallRate(const double rate)