WPILibC++ 2026.2.1
Loading...
Searching...
No Matches
frc::MedianFilter< T > Class Template Reference

A class that implements a moving-window median filter. More...

#include <frc/filter/MedianFilter.h>

Public Member Functions

constexpr MedianFilter (size_t size)
 Creates a new MedianFilter.
 
constexpr T Calculate (T next)
 Calculates the moving-window median for the next value of the input stream.
 
constexpr T LastValue () const
 Returns the last value calculated by the MedianFilter.
 
constexpr void Reset ()
 Resets the filter, clearing the window of all elements.
 

Detailed Description

template<class T>
class frc::MedianFilter< T >

A class that implements a moving-window median filter.

Useful for reducing measurement noise, especially with processes that generate occasional, extreme outliers (such as values from vision processing, LIDAR, or ultrasonic sensors).

Constructor & Destructor Documentation

◆ MedianFilter()

template<class T >
frc::MedianFilter< T >::MedianFilter ( size_t size)
inlineexplicitconstexpr

Creates a new MedianFilter.

Parameters
sizeThe number of samples in the moving window.

Member Function Documentation

◆ Calculate()

template<class T >
T frc::MedianFilter< T >::Calculate ( T next)
inlineconstexpr

Calculates the moving-window median for the next value of the input stream.

Parameters
nextThe next input value.
Returns
The median of the moving window, updated to include the next value.

◆ LastValue()

template<class T >
T frc::MedianFilter< T >::LastValue ( ) const
inlineconstexpr

Returns the last value calculated by the MedianFilter.

Returns
The last value.

◆ Reset()

template<class T >
void frc::MedianFilter< T >::Reset ( )
inlineconstexpr

Resets the filter, clearing the window of all elements.


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