Public Member Functions | Private Attributes | List of all members
roswrap::WallRate Class Reference

Class to help run loops at a desired frequency. This version always uses wall-clock time. More...

#include <rate.h>

Public Member Functions

WallDuration cycleTime () const
 Get the actual run time of a cycle from start to sleep. More...
 
WallDuration expectedCycleTime () const
 Get the expected cycle time – one over the frequency passed in to the constructor. More...
 
void reset ()
 Sets the start time for the rate to now. More...
 
bool sleep ()
 Sleeps for any leftover time in a cycle. Calculated from the last time sleep, reset, or the constructor was called. More...
 
 WallRate (const Duration &)
 
 WallRate (double frequency)
 Constructor, creates a Rate. More...
 

Private Attributes

WallDuration actual_cycle_time_
 
WallDuration expected_cycle_time_
 
WallTime start_
 

Detailed Description

Class to help run loops at a desired frequency. This version always uses wall-clock time.

Definition at line 93 of file rate.h.

Constructor & Destructor Documentation

◆ WallRate() [1/2]

roswrap::WallRate::WallRate ( double  frequency)

Constructor, creates a Rate.

Parameters
frequencyThe desired rate to run at in Hz

Definition at line 138 of file rate.cpp.

◆ WallRate() [2/2]

roswrap::WallRate::WallRate ( const Duration d)
explicit

Definition at line 144 of file rate.cpp.

Member Function Documentation

◆ cycleTime()

WallDuration roswrap::WallRate::cycleTime ( ) const

Get the actual run time of a cycle from start to sleep.

Returns
The runtime of the cycle

Definition at line 191 of file rate.cpp.

◆ expectedCycleTime()

WallDuration roswrap::WallRate::expectedCycleTime ( ) const
inline

Get the expected cycle time – one over the frequency passed in to the constructor.

Definition at line 123 of file rate.h.

◆ reset()

void roswrap::WallRate::reset ( )

Sets the start time for the rate to now.

Definition at line 186 of file rate.cpp.

◆ sleep()

bool roswrap::WallRate::sleep ( )

Sleeps for any leftover time in a cycle. Calculated from the last time sleep, reset, or the constructor was called.

Returns
Passes through the return value from WallDuration::sleep() if it slept, false otherwise.

Definition at line 150 of file rate.cpp.

Member Data Documentation

◆ actual_cycle_time_

WallDuration roswrap::WallRate::actual_cycle_time_
private

Definition at line 127 of file rate.h.

◆ expected_cycle_time_

WallDuration roswrap::WallRate::expected_cycle_time_
private

Definition at line 127 of file rate.h.

◆ start_

WallTime roswrap::WallRate::start_
private

Definition at line 126 of file rate.h.


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


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:15