← Back to ratslair.com
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdvin <[email protected]>2025-05-06 12:17:53 +0200
committerEdvin <[email protected]>2025-05-06 12:17:53 +0200
commit8a4fd87622cc13ca4f501b98502585ca2b2aaddd (patch)
tree985659b1c1efa994f43ef93be739fa1f9b4c7f66
parent66557fa2666712e205924544e60afe46c13b0a24 (diff)
Hopefully fixed DWM reading incorrect values at first
-rwxr-xr-xDWM.py3
-rwxr-xr-xmain.py5
2 files changed, 6 insertions, 2 deletions
diff --git a/DWM.py b/DWM.py
index cfe7178..ebefb3b 100755
--- a/DWM.py
+++ b/DWM.py
@@ -77,6 +77,9 @@ with serial.Serial('/dev/ttyACM0', 115200, timeout = 1) as s:
sleep(0.1)
s.write(b"\r")
sleep(0.1)
+
+ for i in range(10):
+ s.readline()
while True:
dstr = s.readline().decode('utf-8').strip('\n')
diff --git a/main.py b/main.py
index 7b04670..01eccb4 100755
--- a/main.py
+++ b/main.py
@@ -81,6 +81,8 @@ if bto.find("Connected") != -1:
#print("Quality factor: " + qf)
# if float(qf) > 80:
print(f"x: {x}, y: {y}")
+ print(f"Current direction: {curDir}")
+ print(f"Desired direction: {desDir}")
if newCommand:
print(f"Command: {bto}")
@@ -151,8 +153,7 @@ if bto.find("Connected") != -1:
# curDir = (math.atan2(curY - oldY, curX - oldX) + math.pi) * (180/math.pi)
# if backward == True:
# a = a - 180
- print(f"Current direction: {curDir}")
- print(f"Desired direction: {desDir}")
+
NANO.write(b"Stop\n")
curDir = math.atan2(y - oldY, x - oldX)