diff options
| author | Edvin <[email protected]> | 2025-05-07 10:53:08 +0200 |
|---|---|---|
| committer | Edvin <[email protected]> | 2025-05-07 10:53:08 +0200 |
| commit | 643c09f30994ace05ffc5deb5417bfd107b07dc8 (patch) | |
| tree | 1024831ca882b97f07e0a39d43f6c0b3c6038edc | |
| parent | 71e0bdd3741f494ae9b66d4dd0af3b899e0e3369 (diff) | |
Added buffers to position files
| -rwxr-xr-x | DWM.py | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1,4 +1,5 @@ import serial +import os from time import sleep from filterpy.kalman import UnscentedKalmanFilter from filterpy.kalman import MerweScaledSigmaPoints @@ -113,14 +114,14 @@ with serial.Serial('/dev/ttyACM0', 115200, timeout = 1) as s: xmean = int(xmean / 50) ymean = int(ymean / 50) - with open("position.txt", "w") as f: + with open("position_buf.txt", "w") as f: print(f"{kfx},{kfy}") - f.write(f"{x},{y}\n") - f.close() + f.write(f"{kfx},{kfy}\n") + os.rename("position_buf.txt", "position.txt") - with open("position_mean.txt", "w") as f: + with open("position_mean_buf.txt", "w") as f: #print(f"xmean: {xmean}, ymean: {ymean}") f.write(f"{xmean},{ymean}\n") - f.close() + os.rename("position_mean_buf.txt", "position_mean.txt") print("Shutting down serial communication") |
