|
TinyRobotics
|
Computes the moving average of a sequence of values. More...
#include <MovingAverage.h>
Public Member Functions | |
| MovingAverage (size_t size) | |
| void | addMeasurement (N value) |
| float | calculate () |
| void | setSize (size_t size) |
| Defines the number of values. | |
Protected Attributes | |
| std::list< N > | values |
| size_t | size = 0 |
Computes the moving average of a sequence of values.
This template class maintains a fixed-size window of the most recent values and efficiently computes their arithmetic mean. It is useful for smoothing noisy sensor data, filtering out short-term fluctuations, and providing a simple low-pass filter in embedded and robotics applications.
| N | Numeric type of the values (e.g., float, int) |