From 97ff0e742ed170577da40211df87998e10a75230 Mon Sep 17 00:00:00 2001
From: Zhaoliang <zhz03@g.ucla.edu>
Date: Mon, 25 Oct 2021 19:22:06 -0700
Subject: [PATCH] keyboard interruption test completed
---
Code/Control/Laptop_Code/main_keyboard.py | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/Code/Control/Laptop_Code/main_keyboard.py b/Code/Control/Laptop_Code/main_keyboard.py
index 5484805..8e2540a 100644
--- a/Code/Control/Laptop_Code/main_keyboard.py
+++ b/Code/Control/Laptop_Code/main_keyboard.py
@@ -329,15 +329,9 @@ def get_key(keyname):
pygame.display.update()
return ans
-def auto_control(serial_port):
- # =================================== tested autonomous control ======================================================
+def auto_control(serial_port,gbx, gby, gb_dist, tx, ty, tz, rx, ry, rz, LIDAR_dist, debugM):
# ===== STEP 1: TAKE ALL INPUT =====
- waitTime = 0.05
- if ml == 1:
- gbx, gby, gb_dist = ball_detection.detectLive(model, minDetectionScore, showSight=True)
- else:
- gbx, gby = -1, -1
- gb_dist = -1
+ # gbx, gby, gb_dist = ball_detection.detectLive(model, minDetectionScore, showSight = True)
line = serial_port.readline()
if line == b'SERIAL_IN_START\r\n':
@@ -352,8 +346,7 @@ def auto_control(serial_port):
# ===== STEP 3: FEED ALL OUTPUT =====
serial_port_out(serial_port, pwm1, pwm2, pwm3, pwm4, dir1, dir2, dir3, dir4)
- time.sleep(waitTime) # second
- # =========================================================================================
+ time.sleep(waitTime)
def decode_ctl(Ctl_com):
pwm1 = Ctl_com[0]
@@ -484,11 +477,12 @@ if __name__ == '__main__':
if get_key('a'):
flag = 1
while (flag == 1):
- auto_control(serial_port)
+ auto_control(serial_port,gbx, gby, gb_dist, tx, ty, tz, rx, ry, rz, LIDAR_dist, debugM)
flag, print_count = keyboard_stop(flag,print_count)
elif get_key('s'):
- stop_all()
+ pwm1, pwm2, pwm3, pwm4, dir1, dir2, dir3, dir4 = stop_all()
+ serial_port_out(serial_port, pwm1, pwm2, pwm3, pwm4, dir1, dir2, dir3, dir4)
print("stop all motors")
elif get_key('m'):
--
GitLab