ctrl-utils
Public Types | Public Member Functions | List of all members
ctrl_utils::Timer Class Reference

#include <timer.h>

Public Types

using Seconds = std::chrono::duration< double >
 
using Clock = std::chrono::steady_clock
 

Public Member Functions

 Timer ()
 
 Timer (double frequency)
 
double freq () const
 
void set_freq (double frequency)
 
double dt () const
 
void set_dt (double dt)
 
double time (bool update=false) const
 
double time_elapsed (bool update=false) const
 
double time_sim () const
 
double average_freq () const
 
unsigned long long num_iters () const
 
void Reset ()
 
void Sleep ()
 

Detailed Description

Timer utility class for use in control loops.

See also
Python: spatialdyn.Timer

Constructor & Destructor Documentation

◆ Timer() [1/2]

ctrl_utils::Timer::Timer ( )
inline

Default constructor that sets the loop frequency to 1000 Hz.

◆ Timer() [2/2]

ctrl_utils::Timer::Timer ( double  frequency)
inline

Constructor that sets the loop frequency.

Parameters
frequencyFrequency of the timer loop [Hz].
See also
Python: spatialdyn.Timer.__init__()

Member Function Documentation

◆ average_freq()

double ctrl_utils::Timer::average_freq ( ) const
inline
Returns
Average frequency since last timer reset in Hz.

◆ dt()

double ctrl_utils::Timer::dt ( ) const
inline
Returns
Timer loop time interval in seconds (1 / frequency).
See also
Python: spatialdyn.Timer.dt

◆ freq()

double ctrl_utils::Timer::freq ( ) const
inline
Returns
Timer loop frequency in Hz.
See also
Python: spatialdyn.Timer.freq

◆ num_iters()

unsigned long long ctrl_utils::Timer::num_iters ( ) const
inline
Returns
Number of loop iterations since last timer reset.
See also
Python: spatialdyn.Timer.num_iters

◆ Reset()

void ctrl_utils::Timer::Reset ( )
inline

Reset timer.

See also
Python: spatialdyn.Timer.reset()

◆ set_dt()

void ctrl_utils::Timer::set_dt ( double  dt)
inline

Set the timer loop time interval in seconds (1 / frequency).

◆ set_freq()

void ctrl_utils::Timer::set_freq ( double  frequency)
inline

Set the timer loop frequency in Hz.

◆ Sleep()

void ctrl_utils::Timer::Sleep ( )
inline

Wait for the next timer loop.

See also
Python: spatialdyn.Timer.sleep()

◆ time()

double ctrl_utils::Timer::time ( bool  update = false) const
inline
Returns
Current CPU time since epoch in seconds.
See also
Python: spatialdyn.Timer.time

◆ time_elapsed()

double ctrl_utils::Timer::time_elapsed ( bool  update = false) const
inline
Returns
CPU time since last timer reset in seconds.
See also
Python: spatialdyn.Timer.time_elapsed

◆ time_sim()

double ctrl_utils::Timer::time_sim ( ) const
inline
Returns
Simulation time since last timer reset in seconds.
See also
Python: spatialdyn.Timer.time_sim

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