From 5aef09bb634fb8d6d7e0aa69502aea2d3bcd2991 Mon Sep 17 00:00:00 2001 From: bmy <2583236812@qq.com> Date: Sat, 17 Aug 2024 22:18:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BD=E8=B5=9B=E5=87=BA=E5=8F=91=E5=89=8D?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: 补充 action 列表检查 pref: 修改 BBALL offset 值 (未同步到其他备份 subtask.py 中) 套用8822参数 --- cfg_subtask.toml | 2 +- subtask.py | 31 +++++++++++++++++++++---------- subtask_8822.py | 10 ++++++++++ subtask_891.py | 10 ++++++++++ subtask_raw.py | 16 +++++++++++++--- 5 files changed, 55 insertions(+), 14 deletions(-) diff --git a/cfg_subtask.toml b/cfg_subtask.toml index 311b0bf..2f538a5 100644 --- a/cfg_subtask.toml +++ b/cfg_subtask.toml @@ -15,7 +15,7 @@ pid_ki = 0 pid_kd = 0 [up_tower] -pid_kp = 1.8 +pid_kp = 1.3 pid_ki = 0 pid_kd = 0 diff --git a/subtask.py b/subtask.py index 75a4dac..3dc9586 100644 --- a/subtask.py +++ b/subtask.py @@ -555,7 +555,7 @@ class put_block(): ret, box = filter.get(tlabel.HOSPITAL) if ret > 0: width = box[0][2] - box[0][0] - if width > 125: #135 130 128 + if width > 125: #FIXME maybe 125 batter return True return False def exec(self): @@ -650,7 +650,7 @@ class get_bball(): time.sleep(0.5) for _ in range(3): by_cmd.send_position_axis_z(30, 155) - calibrate_right_new(tlabel.BBALL, offset = 18, run = True, run_speed = 5) + calibrate_right_new(tlabel.BBALL, offset = 10, run = True, run_speed = 5) logger.info("抓蓝色球") time.sleep(0.5) by_cmd.send_angle_claw_arm(45) @@ -709,7 +709,7 @@ class up_tower(): calibrate_new(tlabel.TOWER, offset = 20, run = True) time.sleep(1) # calibrate(tlabel.TOWER, 27, False, 6) - by_cmd.send_distance_x(-10, 100) + by_cmd.send_distance_x(-10, 100) # used to be 120 time.sleep(1) # 上古參數 # by_cmd.send_distance_y(-10, 50) # 80 @@ -724,10 +724,11 @@ class up_tower(): # by_cmd.send_speed_y(-10) # time.sleep(0.15) # 8822 - # by_cmd.send_distance_y(-10, 50) - # 891 - by_cmd.send_distance_y(-10, 35) + by_cmd.send_distance_y(-10, 50) time.sleep(0.3) + # 891 + # by_cmd.send_distance_y(-10, 35) + # time.sleep(0.3) by_cmd.send_angle_zhuan(10) time.sleep(12) @@ -784,11 +785,11 @@ class get_rball(): # time.sleep(2) # car_stop() # 8822 参数 - # by_cmd.send_distance_y(-15, 40) - # time.sleep(1.5) - # 891 参数 by_cmd.send_distance_y(-15, 40) - time.sleep(0.3) + time.sleep(0.5) + # 891 参数 + # by_cmd.send_distance_y(-15, 40) + # time.sleep(0.3) calibrate_new(tlabel.RBALL,offset = 44, run = True) time.sleep(1) logger.info("抓红球") @@ -1547,6 +1548,16 @@ class move_area2(): if len(resp_commands) == 0: return action_list = resp_commands + + # 先检查一下 action 是否生成正确,如果不正确直接跳过 + actions_keys = self.action_dict.keys() + try: + for action in action_list: + if not (action.get('action') in actions_keys): + return + except: + return + # 进入停车区域 by_cmd.send_distance_y(10, 450) time.sleep((450 * 5 / 1000) + 0.5) diff --git a/subtask_8822.py b/subtask_8822.py index 1669413..d9427c5 100644 --- a/subtask_8822.py +++ b/subtask_8822.py @@ -1548,6 +1548,16 @@ class move_area2(): if len(resp_commands) == 0: return action_list = resp_commands + + # 先检查一下 action 是否生成正确,如果不正确直接跳过 + actions_keys = self.action_dict.keys() + try: + for action in action_list: + if not (action.get('action') in actions_keys): + return + except: + return + # 进入停车区域 by_cmd.send_distance_y(10, 450) time.sleep((450 * 5 / 1000) + 0.5) diff --git a/subtask_891.py b/subtask_891.py index 75a4dac..4b6237b 100644 --- a/subtask_891.py +++ b/subtask_891.py @@ -1547,6 +1547,16 @@ class move_area2(): if len(resp_commands) == 0: return action_list = resp_commands + + # 先检查一下 action 是否生成正确,如果不正确直接跳过 + actions_keys = self.action_dict.keys() + try: + for action in action_list: + if not (action.get('action') in actions_keys): + return + except: + return + # 进入停车区域 by_cmd.send_distance_y(10, 450) time.sleep((450 * 5 / 1000) + 0.5) diff --git a/subtask_raw.py b/subtask_raw.py index deb0f70..968afe1 100644 --- a/subtask_raw.py +++ b/subtask_raw.py @@ -555,7 +555,7 @@ class put_block(): ret, box = filter.get(tlabel.HOSPITAL) if ret > 0: width = box[0][2] - box[0][0] - if width > 130: #135 + if width > 125: #135 return True return False def exec(self): @@ -650,7 +650,7 @@ class get_bball(): time.sleep(0.5) for _ in range(3): by_cmd.send_position_axis_z(30, 155) - calibrate_right_new(tlabel.BBALL, offset = 18, run = True, run_speed = 5) + calibrate_right_new(tlabel.BBALL, offset = 10, run = True, run_speed = 5) logger.info("抓蓝色球") time.sleep(0.5) by_cmd.send_angle_claw_arm(45) @@ -775,7 +775,7 @@ class get_rball(): by_cmd.send_angle_scoop(20) # 上古參數 # by_cmd.send_distance_y(-15, 50) # 50 # 70 - by_cmd.send_istance_y(-15, 40) # 50 # 70 + by_cmd.send_distance_y(-15, 40) # 50 # 70 time.sleep(0.5) # 6_9 參數 # by_cmd.send_distance_y(-15, 35) @@ -1548,6 +1548,16 @@ class move_area2(): if len(resp_commands) == 0: return action_list = resp_commands + + # 先检查一下 action 是否生成正确,如果不正确直接跳过 + actions_keys = self.action_dict.keys() + try: + for action in action_list: + if not (action.get('action') in actions_keys): + return + except: + return + # 进入停车区域 by_cmd.send_distance_y(10, 450) time.sleep((450 * 5 / 1000) + 0.5)