From 6f659c01d3b02bbd2ac83186f78ddece62947a4e Mon Sep 17 00:00:00 2001
From: Zhiying Li <zhiyingli@g.ucla.edu>
Date: Mon, 15 Nov 2021 09:40:34 -0800
Subject: [PATCH] update current progress

---
 Code/Control/Laptop_Code/main_joystick_1_6.py |  2 +-
 Code/Control/Laptop_Code/main_joystick_4_2.py | 23 ++++++++++++++-----
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/Code/Control/Laptop_Code/main_joystick_1_6.py b/Code/Control/Laptop_Code/main_joystick_1_6.py
index 1141e5d..24efeb5 100644
--- a/Code/Control/Laptop_Code/main_joystick_1_6.py
+++ b/Code/Control/Laptop_Code/main_joystick_1_6.py
@@ -558,7 +558,7 @@ if __name__ == '__main__':
 
     # =========== DECLARE VARIABLES ===========
     # game controller id
-    controller_id = 0 # default is 0 if you plug in only one game controller
+    controller_id = 1 # default is 0 if you plug in only one game controller
 
     # ESP CAM In
     gbx, gby = -1, -1  # by default (-1 means no found green ball)
diff --git a/Code/Control/Laptop_Code/main_joystick_4_2.py b/Code/Control/Laptop_Code/main_joystick_4_2.py
index 85ad4e5..c58d18a 100644
--- a/Code/Control/Laptop_Code/main_joystick_4_2.py
+++ b/Code/Control/Laptop_Code/main_joystick_4_2.py
@@ -8,7 +8,7 @@ from ESP32_AT.imageTread_AT import get_AT_6DOF_info
 
 global mc_print,ml_on,esp_cam_on,feather_data_on
 
-url_gb = 'http://10.0.0.5/cam-hi.jpg'
+url_gb = 'http://10.0.0.29/cam-hi.jpg'
 url_AT = 'http://10.0.0.9/cam-hi.jpg'
 
 mc_print = 1 # manual control print flag
@@ -60,6 +60,8 @@ def manual_horizontal():
     return abs(pwm3),abs(pwm4),dir3,dir4
 
 def manual_control():
+    # gbx, gby, gb_dist = ball_detection.detectLive(url_gb, model, minDetectionScore, showSight=True, detectFlag=False)
+    # tid, tx, ty, tz, rx, ry, rz = get_AT_6DOF_info(url_AT, detectFlag=False)
     pwm1,pwm2,dir1,dir2 = manual_vertical()
     pwm3,pwm4,dir3,dir4 = manual_horizontal()
     if mc_print == 1:
@@ -171,23 +173,29 @@ def auto_init(serial_port,auto_init_count):
 def auto_control(serial_port,gbx, gby, gb_dist, tx, ty, tz, rx, ry, rz, LIDAR_dist1, LIDAR_dist2, debugM):
     # Ctl_com = [0, 0, 0, 0, "+", "+", "+", "+"]
 
-    if ml_on == 1:
+    if ml_on == 1: # and ballCapture == False:
         gbx, gby, gb_dist = ball_detection.detectLive(url_gb, model, minDetectionScore, showSight=True)
         print("gbx,gby:{},{}".format(gbx, gby))
+    # else:
+    #     gbx, gby, gb_dist = -1,-1,-1
 
     line = serial_port.readline()
-    if feather_data_on == 1:
+    if feather_data_on == 1: # and ballCapture == True:
         if line == b'SERIAL_IN_START\r\n':
             tx, ty, tz, rx, ry, rz, LIDAR_dist1, LIDAR_dist2, debugM = serial_port_in_v1(serial_port)
             # only getting the Lidar data back
-            time.sleep(waitTime) # in second
+            # time.sleep(waitTime) # in second
+    # elif feather_data_on == 1:
+    #     tx, ty, tz, rx, ry, rz, LIDAR_dist1, LIDAR_dist2, debugM = 0,0,0,0,0,0,0,0,""
 
-    if esp_cam_on == 1:
+    if esp_cam_on == 1: # and ballCapture == True:
         # ids,txs,tys,tzs,rxs,rys,rzs = get_AT_6DOF_info_list(url_AT)
         tid, tx, ty, tz, rx, ry, rz = get_AT_6DOF_info(url_AT)
         # LIDAR_dist1 = 0
         # LIDAR_dist2 = 0
         # debugM = "Using Esp32 cam"
+    # elif esp_cam_on == 1:
+    #     tx, ty, tz, rx, ry, rz = 0,0,0,0,0,0
 
     # main auto control loop
     Ctl_com = main_control(gbx, gby, gb_dist, tx, ty, tz, rx, ry, rz, LIDAR_dist1, LIDAR_dist2, debugM, bcap_man)
@@ -204,6 +212,9 @@ def manual_in_auto(Ctl_com, serial_port, flag):
         Ctl_com = manual_control()
         serial_port_out(serial_port, Ctl_com)
         flag = manual_return2auto(flag)
+    # gbx, gby, gb_dist = ball_detection.detectLive(url_gb, model, minDetectionScore, showSight=True, detectFlag=False)
+    # tid, tx, ty, tz, rx, ry, rz = get_AT_6DOF_info(url_AT, detectFlag=False)
+
     return flag
 
 def manual_return2auto(flag):
@@ -525,7 +536,7 @@ if __name__ == '__main__':
     serial_port.open()
 
     # Weit Time
-    waitTime = 0.05
+    waitTime = 0.01
 
     # define game controller axes value
     axes_win = dict(
-- 
GitLab