RobWorkProject  23.9.11-
Public Member Functions | List of all members
MovingAverage Class Reference

calculates the moving average over a continues input of samples. More...

#include <MovingAverage.hpp>

Public Member Functions

 MovingAverage (std::size_t N)
 constructor creates a MovingAverage filter over a window of N samples. More...
 
void addSample (double sample)
 adds a sample More...
 
double getAverage ()
 returns the current average More...
 

Detailed Description

calculates the moving average over a continues input of samples.

A circular buffer is maintained so that the last N samples can be inspected. the sum of values in this buffer is also maintained such that the average can be efficiently calculated.

Constructor & Destructor Documentation

◆ MovingAverage()

MovingAverage ( std::size_t  N)

constructor creates a MovingAverage filter over a window of N samples.

Parameters
N[in] the size of the window of samples

Member Function Documentation

◆ addSample()

void addSample ( double  sample)
inline

adds a sample

Parameters
sample

◆ getAverage()

double getAverage ( )
inline

returns the current average

Returns

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