fix: nav2_navigator _get_current_pose uses /amcl_pose (was /odom which is always 0,0)

This commit is contained in:
ywb
2026-05-17 10:15:43 +08:00
parent 5f0fa2e787
commit ea4d592ea3
+1 -1
View File
@@ -121,7 +121,7 @@ class Nav2Navigator:
def _get_current_pose(self) -> List[float]: def _get_current_pose(self) -> List[float]:
"""从 /odom 获取当前位置 [x, y, yaw]""" """从 /odom 获取当前位置 [x, y, yaw]"""
try: try:
rc, out, err = _run_ros2_bash("timeout 3 ros2 topic echo /odom --once 2>/dev/null", timeout=4) rc, out, err = _run_ros2_bash("timeout 3 ros2 topic echo /amcl_pose --once 2>/dev/null", timeout=4)
if rc == 0 and out: if rc == 0 and out:
import re, yaml import re, yaml
clean = re.sub(r'\x1b\[[0-9;]*[a-zA-Z]', '', out) clean = re.sub(r'\x1b\[[0-9;]*[a-zA-Z]', '', out)