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

Class to help run loops at a desired frequency. More...

#include <rate.h>

Public Member Functions

Duration cycleTime () const
 Get the actual run time of a cycle from start to sleep. More...
 
Duration expectedCycleTime () const
 Get the expected cycle time – one over the frequency passed in to the constructor. More...
 
 Rate (const Duration &)
 
 Rate (double frequency)
 Constructor, creates a Rate. 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...
 

Private Attributes

Duration actual_cycle_time_
 
Duration expected_cycle_time_
 
Time start_
 

Detailed Description

Class to help run loops at a desired frequency.

Definition at line 52 of file rate.h.

Constructor & Destructor Documentation

◆ Rate() [1/2]

roswrap::Rate::Rate ( double  frequency)

Constructor, creates a Rate.

Parameters
frequencyThe desired rate to run at in Hz

Definition at line 77 of file rate.cpp.

◆ Rate() [2/2]

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

Definition at line 83 of file rate.cpp.

Member Function Documentation

◆ cycleTime()

Duration roswrap::Rate::cycleTime ( ) const

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

Returns
The runtime of the cycle

Definition at line 133 of file rate.cpp.

◆ expectedCycleTime()

Duration roswrap::Rate::expectedCycleTime ( ) const
inline

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

Definition at line 82 of file rate.h.

◆ reset()

void roswrap::Rate::reset ( )

Sets the start time for the rate to now.

Definition at line 128 of file rate.cpp.

◆ sleep()

bool roswrap::Rate::sleep ( )

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

Returns
True if the desired rate was met for the cycle, false otherwise.

Definition at line 91 of file rate.cpp.

Member Data Documentation

◆ actual_cycle_time_

Duration roswrap::Rate::actual_cycle_time_
private

Definition at line 86 of file rate.h.

◆ expected_cycle_time_

Duration roswrap::Rate::expected_cycle_time_
private

Definition at line 86 of file rate.h.

◆ start_

Time roswrap::Rate::start_
private

Definition at line 85 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