Skip to content

Commit

Permalink
Fix the return type of Rate::period. (#2301)
Browse files Browse the repository at this point in the history
In a recent commit (bc43577),
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 <[email protected]>
  • Loading branch information
clalancette authored Sep 8, 2023
1 parent 38734d7 commit dd6fad6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rclcpp/include/rclcpp/rate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class Rate : public RateBase
reset();

RCLCPP_PUBLIC
Duration
std::chrono::nanoseconds
period() const;

private:
Expand Down
5 changes: 3 additions & 2 deletions rclcpp/src/rclcpp/rate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "rclcpp/rate.hpp"

#include <chrono>
#include <stdexcept>

namespace rclcpp
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit dd6fad6

Please sign in to comment.