mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 06:33:57 +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
|
|
|
|
|