This commit is contained in:
havoc420ubuntu 2025-05-14 12:12:57 +00:00
parent 4cf9f143dd
commit c0de61e1a9
3 changed files with 6 additions and 4 deletions

View File

@ -166,14 +166,15 @@ def move_to_hori_line(ctrl, msg, target_distance=0.1, observe=False):
bool: 是否成功到达目标位置 bool: 是否成功到达目标位置
""" """
# 首先校准到水平 # 首先校准到水平
aligned = align_to_horizontal_line(ctrl, msg, observe=observe) aligned = align_to_horizontal_line(ctrl, msg, observe=False)
if not aligned: if not aligned:
print("无法校准到横向线水平,停止移动") print("无法校准到横向线水平,停止移动")
return False return False
# 检测横向线 # 检测横向线
edge_point, edge_info = detect_horizontal_track_edge(ctrl.image_processor.get_current_image(), observe=observe) cv2.imwrite("current_image.jpg", ctrl.image_processor.get_current_image())
edge_point, edge_info = detect_horizontal_track_edge(ctrl.image_processor.get_current_image(), observe=False)
if edge_point is None or edge_info is None: if edge_point is None or edge_info is None:
print("无法检测到横向线,停止移动") print("无法检测到横向线,停止移动")

BIN
current_image.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@ -5,14 +5,15 @@ import os
# 添加父目录到路径以便能够导入utils # 添加父目录到路径以便能够导入utils
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from base_move.move_base_hori_line import align_to_horizontal_line, move_to_hori_line from base_move.move_base_hori_line import align_to_horizontal_line, move_to_hori_line
observe = True
def run_task_1(ctrl, msg): def run_task_1(ctrl, msg):
print('Running task 1...') print('Running task 1...')
# v2 # v2
move_to_hori_line(ctrl, msg) move_to_hori_line(ctrl, msg, observe=observe)