mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-19 02:54:01 +08:00
11 lines
214 B
Python
11 lines
214 B
Python
class FirstOrderFilter():
|
|
# first order filter
|
|
def __init__(self, x0, ts, dt):
|
|
self.k = (dt / ts) / (1. + dt / ts)
|
|
self.x = x0
|
|
|
|
def update(self, x):
|
|
self.x = (1. - self.k) * self.x + self.k * x
|
|
|
|
|