mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-06-22 01:32:07 +08:00
7062c6dcc4
old-commit-hash: a422246dc3
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
|
|
|
|
|