fix: task-1
This commit is contained in:
parent
5e14311103
commit
84ffa50dc1
@ -22,7 +22,10 @@ logger = get_logger("任务1")
|
||||
|
||||
observe = True
|
||||
|
||||
direction = True
|
||||
|
||||
def run_task_1(ctrl, msg, time_sleep=5000):
|
||||
global direction
|
||||
section('任务1:寻找横线并绕行', "启动")
|
||||
info('开始执行任务1...', "启动")
|
||||
|
||||
@ -36,13 +39,13 @@ def run_task_1(ctrl, msg, time_sleep=5000):
|
||||
section('任务1-1:转弯并扫描QR码', "移动")
|
||||
# 在 arc_turn_around_hori_line 中启用 QR 码扫描
|
||||
turn_success, res = arc_turn_around_hori_line(
|
||||
pass_align=True,
|
||||
radius=1.5,
|
||||
# pass_align=True, // TEST 测试用,直接以 1.5 m 半径右转。
|
||||
# radius=1.5,
|
||||
ctrl=ctrl,
|
||||
msg=msg,
|
||||
angle_deg=-85, # 负值表示右转
|
||||
angle_deg=-85, # 负值表示右转 # INFO 目前来看,这个 -85 + 内部的微调,跟镜像里不断测试出来的效果好了很多,暂时可用。
|
||||
#
|
||||
observe=observe,
|
||||
observe=False, # INFO 暂时关闭观察
|
||||
scan_qrcode=True, # 启用 QR 码扫描
|
||||
qr_check_interval=0.3 # 每 0.3 秒检查一次扫描结果
|
||||
)
|
||||
@ -53,15 +56,15 @@ def run_task_1(ctrl, msg, time_sleep=5000):
|
||||
warning("任务1-1中未能扫描到任何QR码", "警告")
|
||||
|
||||
section('任务1-2:移动到横线', "移动")
|
||||
# 执行常规的移动操作,不需要 QR 码扫描
|
||||
# 执行常规的移动操作
|
||||
move_to_hori_line(ctrl, msg, target_distance=1.1, observe=observe)
|
||||
|
||||
section('任务1-3:转弯', "旋转")
|
||||
direction = False # if res['qr_result'] == 'A-2' else True
|
||||
direction = False if res['qr_result'] == 'A-1' else True # TODO 需要检查一下,这个方向是否正确
|
||||
turn_success, res = arc_turn_around_hori_line(
|
||||
ctrl=ctrl,
|
||||
msg=msg,
|
||||
angle_deg=-170, # 负值表示右转
|
||||
angle_deg=-170 if direction else 170, # TODO need check
|
||||
target_distance=0.6,
|
||||
min_radius=0.3,
|
||||
max_radius=0.4,
|
||||
@ -92,7 +95,7 @@ def run_task_1(ctrl, msg, time_sleep=5000):
|
||||
section('任务1-5:模拟装货', "停止")
|
||||
info('机器人躺下,模拟装货过程', "信息")
|
||||
start_time = time.time()
|
||||
ctrl.base_msg.lie_down(wait_time=time_sleep) # TODO 比赛时改成 5s
|
||||
ctrl.base_msg.lie_down(wait_time=time_sleep)
|
||||
elapsed = time.time() - start_time
|
||||
timing("装货过程", elapsed)
|
||||
|
||||
@ -117,7 +120,7 @@ def run_task_1(ctrl, msg, time_sleep=5000):
|
||||
ctrl=ctrl,
|
||||
msg=msg,
|
||||
radius=radius,
|
||||
angle_deg=85,
|
||||
angle_deg=85 if direction else -85,
|
||||
#
|
||||
pass_align=True,
|
||||
observe=observe,
|
||||
@ -139,16 +142,16 @@ def run_task_1(ctrl, msg, time_sleep=5000):
|
||||
def run_task_1_back(ctrl, msg, time_sleep=5000):
|
||||
section('任务1-11: 返回', "移动")
|
||||
go_straight(ctrl, msg, distance=0.2, observe=observe)
|
||||
turn_degree_v2(ctrl, msg, -90, absolute=True)
|
||||
turn_degree_v2(ctrl, msg, -90, absolute=True) # 不确定 odo 效果如何;
|
||||
|
||||
section('任务1-11: 直线移动', "移动")
|
||||
move_to_hori_line(ctrl, msg, target_distance=0.2, observe=observe)
|
||||
|
||||
section('任务1-12: 90度旋转', "旋转")
|
||||
section('任务1-12: 180度旋转', "旋转")
|
||||
turn_success, res = arc_turn_around_hori_line(
|
||||
ctrl=ctrl,
|
||||
msg=msg,
|
||||
angle_deg=170,
|
||||
angle_deg=170 if direction else -170,
|
||||
target_distance=0.6,
|
||||
min_radius=0.3,
|
||||
max_radius=0.4,
|
||||
@ -182,7 +185,7 @@ def run_task_1_back(ctrl, msg, time_sleep=5000):
|
||||
turn_success, res = arc_turn_around_hori_line(
|
||||
ctrl=ctrl,
|
||||
msg=msg,
|
||||
angle_deg=-85,
|
||||
angle_deg=-85 if direction else 85,
|
||||
radius=res['radius'] * 2,
|
||||
pass_align=True,
|
||||
observe=observe,
|
||||
@ -195,7 +198,6 @@ def run_task_1_back(ctrl, msg, time_sleep=5000):
|
||||
turn_degree_v2(ctrl, msg, degree=0, absolute=True)
|
||||
|
||||
go_straight(ctrl, msg, distance=-1.3, observe=observe)
|
||||
|
||||
# go_to_xy(ctrl, msg, target_x=-0.2, target_y=0, observe=observe)
|
||||
# go_to_xy(ctrl, msg, target_x=-0.2, target_y=0, observe=observe) # TEST
|
||||
|
||||
success("任务1-back完成", "完成")
|
Loading…
x
Reference in New Issue
Block a user