diff --git a/base_move/move_base_hori_line.py b/base_move/move_base_hori_line.py index 3087286..ea40cb1 100644 --- a/base_move/move_base_hori_line.py +++ b/base_move/move_base_hori_line.py @@ -409,7 +409,7 @@ def arc_turn_around_hori_line(ctrl, msg, target_distance=0.5, angle_deg=90, left ctrl.Send_cmd(msg) # 记录起始角度和位置 - start_yaw = ctrl.odo_msg.yaw + start_yaw = ctrl.odo_msg.rpy[2] start_position = list(ctrl.odo_msg.xyz) # 计算圆弧长度 @@ -428,10 +428,13 @@ def arc_turn_around_hori_line(ctrl, msg, target_distance=0.5, angle_deg=90, left dy = current_position[1] - start_position[1] distance_moved = math.sqrt(dx*dx + dy*dy) # 计算已旋转角度 - current_yaw = ctrl.odo_msg.yaw + current_yaw = ctrl.odo_msg.rpy[2] angle_turned = current_yaw - start_yaw # 角度归一化处理 - # ... + while angle_turned > math.pi: + angle_turned -= 2 * math.pi + while angle_turned < -math.pi: + angle_turned += 2 * math.pi time.sleep(0.05) # 5. 发送停止指令