From beb0c1b9f11d121f438faa2287acf244aac02a02 Mon Sep 17 00:00:00 2001 From: havoc420ubuntu <2993167370@qq.com> Date: Sat, 31 May 2025 15:55:00 +0000 Subject: [PATCH] Enhance main.py and task functions by removing commented-out code and refining movement logic. Update task 2.5 to utilize a new turning function and adjust iteration parameters in task 3 for improved execution flow and clarity. --- main.py | 10 +++++----- task_2_5/task_2_5.py | 4 ++-- task_3/task_3.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index ca309f0..be9d559 100644 --- a/main.py +++ b/main.py @@ -51,13 +51,13 @@ def main(): Ctrl.base_msg.stop() # BUG 垃圾指令 for eat # time.sleep(100) # TEST, - # run_task_1(Ctrl, msg, time_sleep=TIME_SLEEP) + run_task_1(Ctrl, msg, time_sleep=TIME_SLEEP) - # arrow_direction = run_task_2(Ctrl, msg, xy_flag=False) - arrow_direction = 'right' # TEST + arrow_direction = run_task_2(Ctrl, msg, xy_flag=False) + # arrow_direction = 'right' # TEST - # info(f"识别到箭头方向: {arrow_direction}", "info") - # run_task_2_5(Ctrl, msg, direction=arrow_direction) + info(f"识别到箭头方向: {arrow_direction}", "info") + run_task_2_5(Ctrl, msg, direction=arrow_direction) if arrow_direction == 'left': run_task_4(Ctrl, msg) diff --git a/task_2_5/task_2_5.py b/task_2_5/task_2_5.py index 2364581..63b55d2 100644 --- a/task_2_5/task_2_5.py +++ b/task_2_5/task_2_5.py @@ -14,11 +14,10 @@ observe = True def run_task_2_5(Ctrl, msg, direction='left'): section('任务2.5:预备进入任务3', "启动") - go_straight(Ctrl, msg, distance=-0.1, speed=0.5, observe=observe) # TEST - turn_degree(Ctrl, msg, 90, absolute=observe) + turn_degree_v2(Ctrl, msg, 90, absolute=observe) section('任务2.5-1:第一次旋转', "移动") @@ -29,6 +28,7 @@ def run_task_2_5(Ctrl, msg, direction='left'): target_distance=0.2, detect_func_version=3, observe=observe, + no_end_reset=True, ) go_straight(Ctrl, msg, distance=0.2, speed=0.5, observe=observe) diff --git a/task_3/task_3.py b/task_3/task_3.py index 3e76a08..f6c7c5e 100644 --- a/task_3/task_3.py +++ b/task_3/task_3.py @@ -101,8 +101,8 @@ def pass_up_down(ctrl, msg): stable_threshold = 8 # 连续15次检测z轴不再增加则认为已经停止 z_speed_threshold = 0.01 # z轴速度阈值,小于这个值认为已经停止爬升 climb_speed_threshold = 0.05 # 检测到开始爬坡的速度阈值 - max_iterations = 320 # 最大循环次数,作为安全保障 - min_iterations = 250 # 最小循环次数,作为安全保障 + max_iterations = 180 # 最大循环次数,作为安全保障 + min_iterations = 170 # 最小循环次数,作为安全保障 # 姿态判断参数 pitch_threshold = 0.05 # 俯仰角阈值(弧度)