Public Member Functions | Protected Attributes | List of all members
ecl::FrequencyMonitor Class Reference

Lightweight and fast frequency monitor. More...

#include <frequency.hpp>

Public Member Functions

const FrequencyDiagnosticsanalyse ()
 Analyse the recent updates to generate monitoring statistics. More...
 
const FrequencyDiagnosticsdiagnostics () const
 Diagnostics getter function. More...
 
 FrequencyMonitor (const float &window_period=2.0, const bool &use_realtime_clock=false)
 Setup the frequency monitor. More...
 
void update ()
 Let the diagnostics know that new data has arrived. More...
 

Protected Attributes

FrequencyDiagnostics current_diagnostics
 
unsigned int incoming_counter
 
ecl::TimeStamp last_anyalsed
 
ecl::TimeStamp last_incoming
 
ecl::TimeStamp maximum_interval
 
ecl::TimeStamp minimum_interval
 
ecl::TimeStamp period
 
bool use_realtime_clock
 

Detailed Description

Lightweight and fast frequency monitor.

This class doesn't dynamically update over a window, nor does it collect and store data to compute characteristics like standard deviations. It is however, suitable for most use case scenarios where you are simply interested in the hz/minimum_interval/maximum_interval of data over a fixed period.

Usage:

float window_period = 2.0;
FrequencyMonitor monitor(window_period, false);
FrequencyMonitor ros_monitor(window_period, true); // use the realtime clock to match ros timestamps
FrequencyDiagnostics diagnostics;
void incomingDataCallback() {
monitor.update(); // register that new data has arrived
}
void process() {
diagnostics = monitor.analyse();
}
void process2() {
monitor.analyse();
diagnostics = monitor.getDiagnostics();
}

Definition at line 89 of file frequency.hpp.

Constructor & Destructor Documentation

◆ FrequencyMonitor()

ecl::FrequencyMonitor::FrequencyMonitor ( const float &  window_period = 2.0,
const bool &  use_realtime_clock = false 
)

Setup the frequency monitor.

Parameters
window_period: time interval over which updates are analysed.
use_realtime_clock: better to use the monotonic clock, but sometimes (e.g. ros), realtime is required.

Definition at line 24 of file lib/frequency.cpp.

Member Function Documentation

◆ analyse()

const FrequencyDiagnostics & ecl::FrequencyMonitor::analyse ( )

Analyse the recent updates to generate monitoring statistics.

Right now this just uses a fixed window (not moving) that only updates the information if the period since the last analyse() request was made has been exceeded.

every two seconds, we update the status as follows

Definition at line 61 of file lib/frequency.cpp.

◆ diagnostics()

const FrequencyDiagnostics& ecl::FrequencyMonitor::diagnostics ( ) const
inline

Diagnostics getter function.

Returns
FrequencyDiagnostics

Definition at line 119 of file frequency.hpp.

◆ update()

void ecl::FrequencyMonitor::update ( )

Let the diagnostics know that new data has arrived.

This updates the internal counter, with a timestamp.

Definition at line 43 of file lib/frequency.cpp.

Member Data Documentation

◆ current_diagnostics

FrequencyDiagnostics ecl::FrequencyMonitor::current_diagnostics
protected

Definition at line 119 of file frequency.hpp.

◆ incoming_counter

unsigned int ecl::FrequencyMonitor::incoming_counter
protected

Definition at line 123 of file frequency.hpp.

◆ last_anyalsed

ecl::TimeStamp ecl::FrequencyMonitor::last_anyalsed
protected

Definition at line 124 of file frequency.hpp.

◆ last_incoming

ecl::TimeStamp ecl::FrequencyMonitor::last_incoming
protected

Definition at line 129 of file frequency.hpp.

◆ maximum_interval

ecl::TimeStamp ecl::FrequencyMonitor::maximum_interval
protected

Definition at line 127 of file frequency.hpp.

◆ minimum_interval

ecl::TimeStamp ecl::FrequencyMonitor::minimum_interval
protected

Definition at line 126 of file frequency.hpp.

◆ period

ecl::TimeStamp ecl::FrequencyMonitor::period
protected

Definition at line 125 of file frequency.hpp.

◆ use_realtime_clock

bool ecl::FrequencyMonitor::use_realtime_clock
protected

Definition at line 128 of file frequency.hpp.


The documentation for this class was generated from the following files:
ecl::FrequencyMonitor::diagnostics
const FrequencyDiagnostics & diagnostics() const
Diagnostics getter function.
Definition: frequency.hpp:119
ecl::FrequencyMonitor::FrequencyMonitor
FrequencyMonitor(const float &window_period=2.0, const bool &use_realtime_clock=false)
Setup the frequency monitor.
Definition: lib/frequency.cpp:24


ecl_time
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:19