Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Loading...
Searching...
No Matches
RollingAvgFilter< T > Class Template Reference

Implements a rolling average filter of the specified type. More...

#include <RollingAvgFilter.h>

Public Member Functions

 RollingAvgFilter (size_t numPoints)
 Construct a new rolling average filter.
 
get () const
 Get the output of the filter.
 
get (const T &val)
 Adds data to the filter and gets the new output.
 
void reset ()
 Clears all data in the buffer.
 
int getSize () const
 Returns the number of points stored in the buffer.
 
int getBufferSize () const
 Get the maximum number of points that can be stored in the buffer.
 
std::list< T > getData () const
 Get the underlying buffer of the filter.
 

Detailed Description

template<typename T>
class RollingAvgFilter< T >

Implements a rolling average filter of the specified type.

Template Parameters
TThe data type to filter. Must support commutative addition as well as scalar division.

Constructor & Destructor Documentation

◆ RollingAvgFilter()

template<typename T>
filters::RollingAvgFilter< T >::RollingAvgFilter ( size_t numPoints)
inlineexplicit

Construct a new rolling average filter.

Parameters
numPointsThe maximum number of points that can be stored in the buffer.

Member Function Documentation

◆ get() [1/2]

template<typename T>
T filters::RollingAvgFilter< T >::get ( ) const
inline

Get the output of the filter.

Behavior is undefined if no data is in the filter.

Returns
The output of the filter.
Warning
If no data is in the filter the behavior is undefined.

◆ get() [2/2]

template<typename T>
T filters::RollingAvgFilter< T >::get ( const T & val)
inline

Adds data to the filter and gets the new output.

Parameters
valThe data to add to the filter.
Returns
The new output of the filter after adding this data.

◆ getBufferSize()

template<typename T>
int filters::RollingAvgFilter< T >::getBufferSize ( ) const
inline

Get the maximum number of points that can be stored in the buffer.

Returns
The maximum number of points that can be stored in the buffer.

◆ getData()

template<typename T>
std::list< T > filters::RollingAvgFilter< T >::getData ( ) const
inline

Get the underlying buffer of the filter.

Returns
A copy of the underlying buffer.

◆ getSize()

template<typename T>
int filters::RollingAvgFilter< T >::getSize ( ) const
inline

Returns the number of points stored in the buffer.

Returns
The number of points stored in the buffer, in the range [0, numPoints]

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