Refactor task execution flow by removing unnecessary return statements and enhancing task 3 with additional centering functionality. Update dual track line detection to improve error handling and variable naming for clarity.
This commit is contained in:
parent
e399c8c837
commit
87be6b8328
2
main.py
2
main.py
@ -64,8 +64,6 @@ def main():
|
||||
else:
|
||||
run_task_3(Ctrl, msg)
|
||||
|
||||
return
|
||||
|
||||
turn_degree_v2(Ctrl, msg, degree=90, absolute=True)
|
||||
run_task_5(Ctrl, msg, direction=arrow_direction)
|
||||
|
||||
|
@ -191,6 +191,7 @@ def pass_up_down(ctrl, msg):
|
||||
# msg.life_count += 1
|
||||
# ctrl.Send_cmd(msg)
|
||||
turn_degree_v2(ctrl, msg, 90, absolute=True)
|
||||
center_on_dual_tracks(ctrl, msg, max_time=15, max_deviation=10.0, observe=False)
|
||||
go_straight(ctrl, msg, distance=0.5, speed=0.5, observe=True)
|
||||
time.sleep(1)
|
||||
# go_to_x_v2(ctrl, msg, 2, speed=0.5, precision=True, observe=True)
|
||||
@ -501,17 +502,15 @@ def run_task_3(ctrl, msg):
|
||||
section('任务3:上下坡', "启动")
|
||||
info('开始执行任务3...', "启动")
|
||||
|
||||
# turn_degree_v2(ctrl, msg, 90, absolute=True)
|
||||
# go_lateral(ctrl, msg, distance=0.2, speed=0.1, observe=True)
|
||||
turn_degree_v2(ctrl, msg, 90, absolute=True)
|
||||
go_lateral(ctrl, msg, distance=0.2, speed=0.1, observe=True)
|
||||
|
||||
# section('任务3-1:up', "开始")
|
||||
# pass_up_down(ctrl, msg)
|
||||
section('任务3-1:up', "开始")
|
||||
pass_up_down(ctrl, msg)
|
||||
|
||||
turn_degree_v2(ctrl, msg, 90, absolute=True)
|
||||
center_on_dual_tracks(ctrl, msg, max_time=15, max_deviation=10.0, observe=False)
|
||||
|
||||
return
|
||||
|
||||
section('任务3-2:yellow stop', "开始")
|
||||
go_until_yellow_area(ctrl, msg, yellow_ratio_threshold=0.15, speed=0.3)
|
||||
|
||||
|
@ -544,11 +544,11 @@ def detect_dual_track_lines(image, observe=False, delay=1000, save_log=True,
|
||||
|
||||
# 计算拟合误差
|
||||
predicted_xs = poly_func(center_ys)
|
||||
error = np.mean(np.abs(predicted_xs - center_xs))
|
||||
err = np.mean(np.abs(predicted_xs - center_xs))
|
||||
|
||||
# 如果误差更小,更新最佳拟合
|
||||
if error < best_error:
|
||||
best_error = error
|
||||
if err < best_error:
|
||||
best_error = err
|
||||
best_poly_coeffs = poly_coeffs
|
||||
except:
|
||||
continue
|
||||
|
Loading…
x
Reference in New Issue
Block a user