From c7ab681c2a157661d10842d2de92fd5774fca0ea Mon Sep 17 00:00:00 2001 From: Havoc <2993167370@qq.com> Date: Wed, 28 May 2025 11:13:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8go=5Fto=5Fxy.py=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0go=5Fto=5Fy=5Fv2=E5=87=BD=E6=95=B0=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=9C=BA=E5=99=A8=E4=BA=BA=E7=A7=BB=E5=8A=A8=E5=88=B0?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E7=9A=84y=E5=9D=90=E6=A0=87=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BA=86=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E7=9A=84=E7=B2=BE=E7=A1=AE=E6=80=A7=E5=92=8C?= =?UTF-8?q?=E7=81=B5=E6=B4=BB=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base_move/go_to_xy.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/base_move/go_to_xy.py b/base_move/go_to_xy.py index 017beb5..162e197 100644 --- a/base_move/go_to_xy.py +++ b/base_move/go_to_xy.py @@ -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)