diff --git a/subtask.py b/subtask.py index 0ed534a..75a4dac 100644 --- a/subtask.py +++ b/subtask.py @@ -787,7 +787,7 @@ class get_rball(): # by_cmd.send_distance_y(-15, 40) # time.sleep(1.5) # 891 参数 - by_cmd.send_distance_y(-15, 30) + by_cmd.send_distance_y(-15, 40) time.sleep(0.3) calibrate_new(tlabel.RBALL,offset = 44, run = True) time.sleep(1) diff --git a/subtask_8822.py b/subtask_8822.py index 0480bea..1669413 100644 --- a/subtask_8822.py +++ b/subtask_8822.py @@ -10,7 +10,6 @@ import toml import zmq import time import variable as var -import action as act import re import math import json @@ -116,7 +115,7 @@ def calibrate_right_new(label, offset, run = True, run_speed = 3.5): ret, error = filter.aim_right(label) error += offset # if ret: - if abs(error) <= 8: + if abs(error) <= 10: car_stop() logger.info("calibrate_right_new:行进时 误差小于 8 直接停车") ret, error = filter.aim_right(label) @@ -233,10 +232,10 @@ def explore_calibrate_new(label, offset, run_direc ,run_speed = 3.5): car_stop() logger.info("explore_calibrate_new:行进时 误差小于 15 直接停车") - ret, box = filter.get(label) - while not ret: - ret, box = filter.get(label) - error = (box[0][2] + box[0][0] - 320) / 2 + offset + # ret, box = filter.get(label) + # while not ret: + # ret, box = filter.get(label) + # error = (box[0][2] + box[0][0] - 320) / 2 + offset logger.info(f"停车后像素误差:{error}") # logger.info(f"explore_calibrate_new:停车后的误差大于 8 使用 distance 校准") @@ -288,10 +287,10 @@ def hanoi_calibrate(target_label, error_label, offset, run_direc ,run_speed = 3. car_stop() logger.info("explore_calibrate_new:行进时 误差小于 15 直接停车") - ret, box = filter.get(target_label) - while not ret: - ret, box = filter.get(target_label) - error = (box[0][2] + box[0][0] - 320) / 2 + offset + # ret, box = filter.get(target_label) + # while not ret: + # ret, box = filter.get(target_label) + # error = (box[0][2] + box[0][0] - 320) / 2 + offset logger.info(f"停车后像素误差:{error}") break return True @@ -426,8 +425,7 @@ class task_queuem(task): class get_block1(): def init(self): var.task_speed = 15 - act.cmd.camera(0) - act.cmd.z2(20, 60, 0) + by_cmd.send_angle_camera(0) filter.switch_camera(1) # if cfg['get_block']['first_block'] == "blue": # self.target_label = tlabel.BBLOCK @@ -464,7 +462,7 @@ class get_block1(): logger.info("抓取块") by_cmd.send_position_axis_z(30, 80) - time.sleep(1) + time.sleep(1.5) by_cmd.send_angle_claw(63) by_cmd.send_position_axis_x(1, 20) time.sleep(1) @@ -557,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: + if width > 130: #FIXME maybe 125 batter return True return False def exec(self): @@ -651,6 +649,7 @@ class get_bball(): car_stop() 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) logger.info("抓蓝色球") time.sleep(0.5) @@ -672,7 +671,7 @@ class get_bball(): time.sleep(0.5) by_cmd.send_angle_claw_arm(45) time.sleep(1) - by_cmd.send_position_axis_z(30, 155) + # by_cmd.send_position_axis_z(30, 155) # 继续向前走 # by_cmd.send_speed_x(4) pass @@ -710,10 +709,10 @@ 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, 120) + by_cmd.send_distance_x(-10, 100) # used to be 120 time.sleep(1) # 上古參數 - by_cmd.send_distance_y(-10, 50) # 80 + # by_cmd.send_distance_y(-10, 50) # 80 # 6_9 模型參數 # by_cmd.send_distance_y(-10, 40) # 7_12_3 模型參數 @@ -724,6 +723,12 @@ class up_tower(): # time.sleep(3) # by_cmd.send_speed_y(-10) # time.sleep(0.15) + # 8822 + 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) @@ -781,7 +786,10 @@ class get_rball(): # car_stop() # 8822 参数 by_cmd.send_distance_y(-15, 40) - time.sleep(1.5) + 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("抓红球") @@ -1105,7 +1113,7 @@ class put_hanoi2(): time.sleep(1) pass # ret = explore_calibrate_new(tlabel.LPILLER, offset = self.offset, run_direc = -1, run_speed = 5) - ret = hanoi_calibrate(tlabel.LPILLER, tlabel.TPLATFORM, offset = self.offset, run_direc = -1, run_speed = 5) + ret = hanoi_calibrate(tlabel.LPILLER, [tlabel.TPLATFORM], offset = self.offset, run_direc = -1, run_speed = 5) if not ret: logger.error("在放中平台的时候出现问题 跳过物资盘点 2 exec") return @@ -1166,7 +1174,7 @@ class put_hanoi2(): time.sleep(2) pass # ret = explore_calibrate_new(tlabel.MPILLER, offset = self.offset, run_direc = -1, run_speed = 5) - ret = hanoi_calibrate(tlabel.MPILLER, tlabel.LPILLER, offset = self.offset, run_direc = -1, run_speed = 5) + ret = hanoi_calibrate(tlabel.MPILLER, [tlabel.LPILLER, tlabel.TPLATFORM], offset = self.offset, run_direc = -1, run_speed = 5) if not ret: logger.error("在放小平台的时候出现问题 跳过物资盘点 2 exec") return diff --git a/subtask_891.py b/subtask_891.py index d463086..75a4dac 100644 --- a/subtask_891.py +++ b/subtask_891.py @@ -10,7 +10,6 @@ import toml import zmq import time import variable as var -import action as act import re import math import json @@ -116,7 +115,7 @@ def calibrate_right_new(label, offset, run = True, run_speed = 3.5): ret, error = filter.aim_right(label) error += offset # if ret: - if abs(error) <= 8: + if abs(error) <= 10: car_stop() logger.info("calibrate_right_new:行进时 误差小于 8 直接停车") ret, error = filter.aim_right(label) @@ -233,10 +232,10 @@ def explore_calibrate_new(label, offset, run_direc ,run_speed = 3.5): car_stop() logger.info("explore_calibrate_new:行进时 误差小于 15 直接停车") - ret, box = filter.get(label) - while not ret: - ret, box = filter.get(label) - error = (box[0][2] + box[0][0] - 320) / 2 + offset + # ret, box = filter.get(label) + # while not ret: + # ret, box = filter.get(label) + # error = (box[0][2] + box[0][0] - 320) / 2 + offset logger.info(f"停车后像素误差:{error}") # logger.info(f"explore_calibrate_new:停车后的误差大于 8 使用 distance 校准") @@ -288,10 +287,10 @@ def hanoi_calibrate(target_label, error_label, offset, run_direc ,run_speed = 3. car_stop() logger.info("explore_calibrate_new:行进时 误差小于 15 直接停车") - ret, box = filter.get(target_label) - while not ret: - ret, box = filter.get(target_label) - error = (box[0][2] + box[0][0] - 320) / 2 + offset + # ret, box = filter.get(target_label) + # while not ret: + # ret, box = filter.get(target_label) + # error = (box[0][2] + box[0][0] - 320) / 2 + offset logger.info(f"停车后像素误差:{error}") break return True @@ -426,8 +425,7 @@ class task_queuem(task): class get_block1(): def init(self): var.task_speed = 15 - act.cmd.camera(0) - act.cmd.z2(20, 60, 0) + by_cmd.send_angle_camera(0) filter.switch_camera(1) # if cfg['get_block']['first_block'] == "blue": # self.target_label = tlabel.BBLOCK @@ -464,7 +462,7 @@ class get_block1(): logger.info("抓取块") by_cmd.send_position_axis_z(30, 80) - time.sleep(1) + time.sleep(1.5) by_cmd.send_angle_claw(63) by_cmd.send_position_axis_x(1, 20) time.sleep(1) @@ -557,7 +555,7 @@ class put_block(): ret, box = filter.get(tlabel.HOSPITAL) if ret > 0: width = box[0][2] - box[0][0] - if width > 128: #135 130 + if width > 125: #135 130 128 return True return False def exec(self): @@ -651,6 +649,7 @@ class get_bball(): car_stop() 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) logger.info("抓蓝色球") time.sleep(0.5) @@ -672,7 +671,7 @@ class get_bball(): time.sleep(0.5) by_cmd.send_angle_claw_arm(45) time.sleep(1) - by_cmd.send_position_axis_z(30, 155) + # by_cmd.send_position_axis_z(30, 155) # 继续向前走 # by_cmd.send_speed_x(4) pass @@ -710,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, 120) + by_cmd.send_distance_x(-10, 100) time.sleep(1) # 上古參數 # by_cmd.send_distance_y(-10, 50) # 80 @@ -788,7 +787,7 @@ class get_rball(): # by_cmd.send_distance_y(-15, 40) # time.sleep(1.5) # 891 参数 - by_cmd.send_distance_y(-15, 30) + by_cmd.send_distance_y(-15, 40) time.sleep(0.3) calibrate_new(tlabel.RBALL,offset = 44, run = True) time.sleep(1) diff --git a/subtask_raw.py b/subtask_raw.py index ff32c6d..deb0f70 100644 --- a/subtask_raw.py +++ b/subtask_raw.py @@ -10,7 +10,6 @@ import toml import zmq import time import variable as var -import action as act import re import math import json @@ -116,7 +115,7 @@ def calibrate_right_new(label, offset, run = True, run_speed = 3.5): ret, error = filter.aim_right(label) error += offset # if ret: - if abs(error) <= 8: + if abs(error) <= 10: car_stop() logger.info("calibrate_right_new:行进时 误差小于 8 直接停车") ret, error = filter.aim_right(label) @@ -233,10 +232,10 @@ def explore_calibrate_new(label, offset, run_direc ,run_speed = 3.5): car_stop() logger.info("explore_calibrate_new:行进时 误差小于 15 直接停车") - ret, box = filter.get(label) - while not ret: - ret, box = filter.get(label) - error = (box[0][2] + box[0][0] - 320) / 2 + offset + # ret, box = filter.get(label) + # while not ret: + # ret, box = filter.get(label) + # error = (box[0][2] + box[0][0] - 320) / 2 + offset logger.info(f"停车后像素误差:{error}") # logger.info(f"explore_calibrate_new:停车后的误差大于 8 使用 distance 校准") @@ -288,10 +287,10 @@ def hanoi_calibrate(target_label, error_label, offset, run_direc ,run_speed = 3. car_stop() logger.info("explore_calibrate_new:行进时 误差小于 15 直接停车") - ret, box = filter.get(target_label) - while not ret: - ret, box = filter.get(target_label) - error = (box[0][2] + box[0][0] - 320) / 2 + offset + # ret, box = filter.get(target_label) + # while not ret: + # ret, box = filter.get(target_label) + # error = (box[0][2] + box[0][0] - 320) / 2 + offset logger.info(f"停车后像素误差:{error}") break return True @@ -426,8 +425,7 @@ class task_queuem(task): class get_block1(): def init(self): var.task_speed = 15 - act.cmd.camera(0) - act.cmd.z2(20, 60, 0) + by_cmd.send_angle_camera(0) filter.switch_camera(1) # if cfg['get_block']['first_block'] == "blue": # self.target_label = tlabel.BBLOCK @@ -464,7 +462,7 @@ class get_block1(): logger.info("抓取块") by_cmd.send_position_axis_z(30, 80) - time.sleep(1) + time.sleep(1.5) by_cmd.send_angle_claw(63) by_cmd.send_position_axis_x(1, 20) time.sleep(1) @@ -651,6 +649,7 @@ class get_bball(): car_stop() 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) logger.info("抓蓝色球") time.sleep(0.5) @@ -672,7 +671,7 @@ class get_bball(): time.sleep(0.5) by_cmd.send_angle_claw_arm(45) time.sleep(1) - by_cmd.send_position_axis_z(30, 155) + # by_cmd.send_position_axis_z(30, 155) # 继续向前走 # by_cmd.send_speed_x(4) pass @@ -710,10 +709,11 @@ 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, 120) + by_cmd.send_distance_x(-10, 100) time.sleep(1) # 上古參數 by_cmd.send_distance_y(-10, 50) # 80 + time.sleep(0.5) # 6_9 模型參數 # by_cmd.send_distance_y(-10, 40) # 7_12_3 模型參數 @@ -724,6 +724,11 @@ class up_tower(): # time.sleep(3) # 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) + # time.sleep(0.3) by_cmd.send_angle_zhuan(10) time.sleep(12) @@ -770,8 +775,8 @@ class get_rball(): by_cmd.send_angle_scoop(20) # 上古參數 # by_cmd.send_distance_y(-15, 50) # 50 # 70 - by_cmd.send_distance_y(-15, 40) # 50 # 70 - time.sleep(1.5) + by_cmd.send_istance_y(-15, 40) # 50 # 70 + time.sleep(0.5) # 6_9 參數 # by_cmd.send_distance_y(-15, 35) # time.sleep(2) @@ -779,6 +784,12 @@ class get_rball(): # by_cmd.send_distance_y(-15, 45) # 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) calibrate_new(tlabel.RBALL,offset = 44, run = True) time.sleep(1) logger.info("抓红球") @@ -826,14 +837,14 @@ class put_bball(): calibrate_new(tlabel.BASKET,offset = -40, run = True, run_speed = 6) # by_cmd.send_distance_x(10, 10) # 向左运动 - by_cmd.send_distance_y(-10, 35) + # by_cmd.send_distance_y(-10, 35) # by_cmd.send_angle_storage(10) # time.sleep(1) by_cmd.send_angle_storage(50) logger.info("把球放篮筐里") - time.sleep(1) + time.sleep(2) # by_cmd.send_distance_y(10, 55) by_cmd.send_angle_storage(20) # time.sleep(1) @@ -1102,7 +1113,7 @@ class put_hanoi2(): time.sleep(1) pass # ret = explore_calibrate_new(tlabel.LPILLER, offset = self.offset, run_direc = -1, run_speed = 5) - ret = hanoi_calibrate(tlabel.LPILLER, tlabel.TPLATFORM, offset = self.offset, run_direc = -1, run_speed = 5) + ret = hanoi_calibrate(tlabel.LPILLER, [tlabel.TPLATFORM], offset = self.offset, run_direc = -1, run_speed = 5) if not ret: logger.error("在放中平台的时候出现问题 跳过物资盘点 2 exec") return @@ -1163,7 +1174,7 @@ class put_hanoi2(): time.sleep(2) pass # ret = explore_calibrate_new(tlabel.MPILLER, offset = self.offset, run_direc = -1, run_speed = 5) - ret = hanoi_calibrate(tlabel.MPILLER, tlabel.LPILLER, offset = self.offset, run_direc = -1, run_speed = 5) + ret = hanoi_calibrate(tlabel.MPILLER, [tlabel.LPILLER, tlabel.TPLATFORM], offset = self.offset, run_direc = -1, run_speed = 5) if not ret: logger.error("在放小平台的时候出现问题 跳过物资盘点 2 exec") return @@ -1537,14 +1548,6 @@ 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) @@ -1656,6 +1659,8 @@ class kick_ass(): # by_cmd.send_speed_x(25) # time.sleep(4) pass + + def nexec(self): pass def after(self):