task-1 #2
This commit is contained in:
		
							parent
							
								
									4cf9f143dd
								
							
						
					
					
						commit
						c0de61e1a9
					
				@ -166,14 +166,15 @@ def move_to_hori_line(ctrl, msg, target_distance=0.1, observe=False):
 | 
			
		||||
    bool: 是否成功到达目标位置
 | 
			
		||||
    """
 | 
			
		||||
    # 首先校准到水平
 | 
			
		||||
    aligned = align_to_horizontal_line(ctrl, msg, observe=observe)
 | 
			
		||||
    aligned = align_to_horizontal_line(ctrl, msg, observe=False)
 | 
			
		||||
    
 | 
			
		||||
    if not aligned:
 | 
			
		||||
        print("无法校准到横向线水平,停止移动")
 | 
			
		||||
        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:
 | 
			
		||||
        print("无法检测到横向线,停止移动")
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								current_image.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								current_image.jpg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 76 KiB  | 
@ -5,14 +5,15 @@ import os
 | 
			
		||||
 | 
			
		||||
# 添加父目录到路径,以便能够导入utils
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
observe = True
 | 
			
		||||
 | 
			
		||||
def run_task_1(ctrl, msg):
 | 
			
		||||
    print('Running task 1...')
 | 
			
		||||
 | 
			
		||||
    # v2
 | 
			
		||||
    move_to_hori_line(ctrl, msg)
 | 
			
		||||
    move_to_hori_line(ctrl, msg, observe=observe)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user