nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
rclcpp::Rate Class Reference

#include <rclcpp.hpp>

Public Member Functions

::rclcpp::Duration period () const
 
 Rate (::rclcpp::Duration period)
 
 Rate (double frequency_hz)
 
void reset ()
 rclcpp::Rate::reset() — anchor the next tick one period from now.
 
bool sleep ()
 

Detailed Description

rclcpp::Rate — a periodic loop rate, driven by the nano-ros executor. See the envelope above; the differences from upstream are real.

Constructor & Destructor Documentation

◆ Rate() [1/2]

rclcpp::Rate::Rate ( double  frequency_hz)
inlineexplicit

Construct from a frequency in Hz. 0 or negative disables the rate: sleep() becomes a no-op returning false.

◆ Rate() [2/2]

rclcpp::Rate::Rate ( ::rclcpp::Duration  period)
inlineexplicit

Construct from a period — rclcpp::Rate(rclcpp::Duration::from_nanoseconds(n)). The always-available spelling, on every target.

Member Function Documentation

◆ period()

::rclcpp::Duration rclcpp::Rate::period ( ) const
inline

The configured period.

rclcpp::Duration rather than std::chrono::nanoseconds (phase-442 W5): a return type that exists only where <chrono> does would keep the whole class hostage to the toolchain, which is what this work item removed. .nanoseconds() is the same number upstream's .count() gives.

◆ reset()

void rclcpp::Rate::reset ( )
inline

rclcpp::Rate::reset() — anchor the next tick one period from now.

◆ sleep()

bool rclcpp::Rate::sleep ( )
inline

Spin the executor until the next tick is due.

Returns
true if there was time left to wait, false if the loop had already overrun the period (upstream's contract) or the rate is disabled.

The documentation for this class was generated from the following file: