- reworked

git-svn-id: http://moon:8086/svn/projects/HendiControl@113 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
2019-03-20 21:11:09 +00:00
parent 9af007906a
commit 69a175beac
8 changed files with 386 additions and 39 deletions
+29
View File
@@ -0,0 +1,29 @@
class Smoother:
def __init__(self, alpha):
self.a = alpha
self.b = 1-alpha
self.y = 0
def process(self, x):
self.y = self.b*self.y + self.a*x
def get_y(self):
return self.y
class Stable:
def __init__(self, stable_count, err_max):
self.stable_time = stable_count
self.count = stable_count
self.err_max = err_max
self.x = 0
def process(self, x):
if self.count > 0:
self.count -= 1
if abs(x - self.x) >= self.err_max:
self.count = self.stable_time
is_stable = (self.count == 0)
return is_stable