From 702ee463dd2629db8d0e3b7275ca8e031f59aa8c Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 11 Aug 2020 18:35:30 +0800 Subject: [PATCH] average position --- dmi.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dmi.py b/dmi.py index bc72266..d8db867 100644 --- a/dmi.py +++ b/dmi.py @@ -35,6 +35,8 @@ def main(): buf_sdr.start() try: throttle = 0 + throttle_factor = 8 + position_acc = 0.0 while True: buffers = buf_sdr.get() try: @@ -43,7 +45,7 @@ def main(): # Throttle certain things to avoid overflows due to the limited speed of # the MHS5200A serial interface and GUI plotting. throttle += 1 - if throttle == 8: + if throttle == throttle_factor: throttle = 0 if throttle == 0: @@ -52,10 +54,13 @@ def main(): if stabilizer.locked(): position = position_tracker.input(samples_ref, samples_meas) + position_acc += np.sum(position)/len(position) if throttle == 0: - gui.update_position(np.sum(position)/len(position)) + gui.update_position(position_acc/throttle_factor) + position_acc = 0.0 else: position_tracker.reset() + position_acc = 0.0 finally: buf_sdr.dispose(buffers) finally: