Class FrequencyMonitor

Class Documentation

class FrequencyMonitor

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();
}

Public Functions

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.

void update()

Let the diagnostics know that new data has arrived.

This updates the internal counter, with a timestamp.

const FrequencyDiagnostics &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.

inline const FrequencyDiagnostics &diagnostics() const

Diagnostics getter function.

Returns:

FrequencyDiagnostics

Protected Attributes

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