44 , expected_cycle_time_(1.0 / frequency)
45 , actual_cycle_time_(0.0)
69 Duration sleep_time = expected_end - actual_end;
75 start_ = expected_end;
82 if (actual_end > expected_end + expected_cycle_time_)
90 return sleep_time.
sleep();
134 start_ = expected_end;
141 if (actual_end > expected_end + expected_cycle_time_)
148 return sleep_time.
sleep();
WallDuration expected_cycle_time_
WallDuration cycleTime() const
Get the actual run time of a cycle from start to sleep.
Time representation. May either represent wall clock time or ROS clock time.
Rate(double frequency)
Constructor, creates a Rate.
bool sleep() const
sleep for the amount of time specified by this Duration. If a signal interrupts the sleep...
Duration cycleTime() const
Get the actual run time of a cycle from start to sleep.
Duration representation for use with the WallTime class.
Time representation. Always wall-clock time.
void reset()
Sets the start time for the rate to now.
bool sleep() const
sleep for the amount of time specified by this Duration. If a signal interrupts the sleep...
Duration expected_cycle_time_
bool sleep()
Sleeps for any leftover time in a cycle. Calculated from the last time sleep, reset, or the constructor was called.
Duration representation for use with the Time class.
static WallTime now()
Returns the current wall clock time.
WallDuration actual_cycle_time_
static Time now()
Retrieve the current time. If ROS clock time is in use, this returns the time according to the ROS cl...
Duration actual_cycle_time_
void reset()
Sets the start time for the rate to now.
WallRate(double frequency)
Constructor, creates a Rate.
bool sleep()
Sleeps for any leftover time in a cycle. Calculated from the last time sleep, reset, or the constructor was called.