在go_to_xy.py中添加go_to_y_v2函数,支持机器人移动到指定的y坐标位置,优化了移动控制的精确性和灵活性。

This commit is contained in:
Havoc 2025-05-28 11:13:19 +08:00
parent b4956329db
commit c7ab681c2a

View File

@ -541,6 +541,7 @@ def go_to_xy_v2(ctrl, msg, target_x, target_y, speed=0.5, precision=True, observ
warning(f"未能精确到达目标点,误差: {final_distance:.3f}", "警告")
return nav_success
def go_to_xy_with_correction_v2(ctrl, msg, target_x, target_y, speed=0.5, precision=True,
max_attempts=2, observe=False):
"""
@ -623,3 +624,16 @@ def go_to_xy_with_correction_v2(ctrl, msg, target_x, target_y, speed=0.5, precis
error(f"多次尝试后仍未能达到目标点,最终误差: {final_distance:.3f}", "失败")
return False
def go_to_y_v2(ctrl, msg, target_y, speed=0.5, precision=True, observe=False):
"""
控制机器人移动到指定的y坐标位置使用直接y速度控制
参数:
ctrl: Robot_Ctrl 对象包含里程计信息
msg: robot_control_cmd_lcmt 对象用于发送命令
target_y: 目标Y坐标()
speed: 行走速度(/)范围0.1~1.0默认为0.5
"""
target_x = ctrl.odo_msg.xyz[0]
return go_to_xy_v2(ctrl, msg, target_x, target_y, speed, precision, observe)