diff options
| author | Edvin <[email protected]> | 2025-05-06 08:29:05 +0200 |
|---|---|---|
| committer | Edvin <[email protected]> | 2025-05-06 08:29:05 +0200 |
| commit | 665301be294bbc1bc378a46d50d0f069bd10b748 (patch) | |
| tree | 0ce4c1d5731a4c16b283dc95a2ec42499f2bf6c0 /gather_pos_data.py | |
| parent | d3c64b9a29abd9ac3d6f812022a554f14a052a6d (diff) | |
Added program to gather position data for noise statistics
Diffstat (limited to 'gather_pos_data.py')
| -rw-r--r-- | gather_pos_data.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/gather_pos_data.py b/gather_pos_data.py new file mode 100644 index 0000000..d7aa467 --- /dev/null +++ b/gather_pos_data.py @@ -0,0 +1,63 @@ +import serial +from time import sleep + +# Gathering data like this we should see that measurements have a normal distribution with +# quality factor weighing results further from the ground truth + +updRate = "1 1" # Active Idle +with open("position.txt", "w") as f: + with serial.Serial('/dev/ttyACM0', 115200, timeout = 1) as s: + + # print(f"Opened serial port {s.name}") + + sleep(1) + s.write(b"\r") + sleep(0.1) + s.write(b"\r") + + s.write(b'nis ') + sleep(0.1) + s.write(b'0x1234') + sleep(0.1) + s.write(b'\r') + # print(f"Set PAN ID to 0x1234") + + sleep(1) + + s.write(b'nmt') + sleep(0.1) + s.write(b'\r') + # print("Configured node as tag") + + sleep(1) + + s.write(b"\r") + sleep(0.1) + s.write(b"\r") + + sleep(2) + + s.write(b"aurs ") + sleep(0.1) + s.write(updRate.encode()) + sleep(0.1) + s.write(b'\r') + # print("Set update rate to " + updRate) + + sleep(0.1) + s.write(b"lep") + sleep(0.1) + s.write(b"\r") + sleep(0.1) + + while True: + str = s.readline().decode('utf-8').strip('\n') + + if "POS," in str: + str = str.replace("POS,", "") + print(str) + + f.write(str + '\n') + f.close() + +print("Shutting down serial communication") |
