diff --git a/Code/Control/Laptop_Code/main_keyboard.py b/Code/Control/Laptop_Code/main_keyboard.py index 5484805f9cb220477814c69e67ce697c21ca3c83..8e2540abcf6e1bd1006da15d0daa60396b2c2048 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'):