- Gazebo Sim (Jetty 10.6) + ROS 2 Lyrical + Nav2 全栈 - 整车模型:URDF/SDF + 减面网格(SolidWorks 装配体实测尺寸) - 场地:RMUL 2027 官方包(2D 栅格地图 + 3D 场地模型),放在 field/ - sentry_nav C++ 包:self_filter 点云自滤 / patrol 航点巡逻 - 文档:README(含本机开发环境实测)、MID-360 接入说明 已排除:build/ install/ log/ 缓存目录,以及 115 MB 的原始高模 (仿真实际用的是 meshes/base.stl 减面版,约 25.7 万面)
43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""诊断 Nav2:代价地图是否在更新、TF 是否完整、能否规划。"""
|
|
import time
|
|
|
|
import rclpy
|
|
from nav_msgs.msg import OccupancyGrid
|
|
from rclpy.node import Node
|
|
from tf2_ros import Buffer, TransformListener
|
|
|
|
rclpy.init()
|
|
node = Node('nav_diag')
|
|
buf = Buffer()
|
|
TransformListener(buf, node)
|
|
grids = {}
|
|
node.create_subscription(OccupancyGrid, '/global_costmap/costmap',
|
|
lambda m: grids.__setitem__('g', (time.time(), m)), 10)
|
|
node.create_subscription(OccupancyGrid, '/local_costmap/costmap',
|
|
lambda m: grids.__setitem__('l', (time.time(), m)), 10)
|
|
node.create_subscription(OccupancyGrid, '/map',
|
|
lambda m: grids.__setitem__('m', (time.time(), m)), 10)
|
|
|
|
t0 = time.time()
|
|
while time.time() - t0 < 12:
|
|
rclpy.spin_once(node, timeout_sec=0.2)
|
|
|
|
for key, name in (('m', '/map'), ('g', 'global_costmap'), ('l', 'local_costmap')):
|
|
if key in grids:
|
|
ts, g = grids[key]
|
|
print(f'{name:16} ✅ 收到 尺寸={g.info.width}x{g.info.height} 分辨率={g.info.resolution} 龄期={time.time()-ts:.1f}s')
|
|
else:
|
|
print(f'{name:16} ❌ 没收到(说明这一环没在发布/更新)')
|
|
|
|
for parent, child in (('map', 'odom'), ('odom', 'base_link'), ('base_link', 'lidar_link')):
|
|
try:
|
|
tr = buf.lookup_transform(parent, child, rclpy.time.Time())
|
|
p = tr.transform.translation
|
|
print(f'TF {parent:9} -> {child:10} ✅ ({p.x:+.2f}, {p.y:+.2f}, {p.z:+.2f})')
|
|
except Exception as exc: # noqa: BLE001
|
|
print(f'TF {parent:9} -> {child:10} ❌ {str(exc)[:60]}')
|
|
|
|
node.destroy_node()
|
|
rclpy.shutdown()
|