Simple Incremental LPF filter
This commit is contained in:
parent
fe69b7764d
commit
a509b29348
17
src/control/lpf.cpp
Normal file
17
src/control/lpf.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "src/control/lpf.h"
|
||||
|
||||
namespace control {
|
||||
|
||||
|
||||
incrementalLPF::incrementalLPF()
|
||||
: m_filtered(0)
|
||||
{
|
||||
}
|
||||
|
||||
double incrementalLPF::filter(double latestValue)
|
||||
{
|
||||
m_filtered = m_filtered*0.95 + latestValue*0.05;
|
||||
return m_filtered;
|
||||
}
|
||||
|
||||
} // namespace control
|
19
src/control/lpf.h
Normal file
19
src/control/lpf.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
namespace control {
|
||||
|
||||
class incrementalLPF
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
incrementalLPF();
|
||||
|
||||
double filter(double latestValue);
|
||||
|
||||
private:
|
||||
|
||||
double m_filtered;
|
||||
};
|
||||
|
||||
} // namespace control
|
Loading…
x
Reference in New Issue
Block a user