15 #ifndef RCLCPP__RATE_HPP_ 16 #define RCLCPP__RATE_HPP_ 34 virtual bool sleep() = 0;
36 virtual void reset() = 0;
43 template<
class Clock = std::chrono::high_resolution_clock>
63 auto next_interval = last_interval_ + period_;
65 if (now < last_interval_) {
67 next_interval = now + period_;
70 auto time_to_sleep = next_interval - now;
72 last_interval_ += period_;
78 if (now > next_interval + period_) {
79 last_interval_ = now + period_;
92 return Clock::is_steady;
119 #endif // RCLCPP__RATE_HPP_
#define RCLCPP_DISABLE_COPY(...)
Definition: macros.hpp:26
virtual bool is_steady() const
Definition: rate.hpp:90
std::chrono::nanoseconds period() const
Definition: rate.hpp:101
Definition: allocator_common.hpp:24
virtual void reset()
Definition: rate.hpp:96
GenericRate(std::chrono::nanoseconds period)
Definition: rate.hpp:53
T duration_cast(T... args)
bool sleep_for(const std::chrono::nanoseconds &nanoseconds)
Use the global condition variable to block for the specified amount of time.
virtual bool sleep()
Definition: rate.hpp:58
#define RCLCPP_SMART_PTR_DEFINITIONS(...)
Definition: macros.hpp:36
#define RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(...)
Definition: macros.hpp:51
virtual bool is_steady() const =0