- 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 万面)
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""对比自滤前后的点云:有没有把车身自身回波滤掉。"""
|
|
import time
|
|
|
|
import rclpy
|
|
from rclpy.node import Node
|
|
from sensor_msgs.msg import PointCloud2
|
|
import sensor_msgs_py.point_cloud2 as pc2
|
|
from rclpy.qos import QoSProfile, QoSReliabilityPolicy
|
|
|
|
QOS = QoSProfile(depth=5, reliability=QoSReliabilityPolicy.BEST_EFFORT)
|
|
rclpy.init()
|
|
node = Node('cloud_compare')
|
|
got = {}
|
|
node.create_subscription(PointCloud2, '/scan/points',
|
|
lambda m: got.setdefault('raw', m), QOS)
|
|
node.create_subscription(PointCloud2, '/scan/points_filtered',
|
|
lambda m: got.setdefault('filtered', m), QOS)
|
|
t0 = time.time()
|
|
while time.time() - t0 < 15 and len(got) < 2:
|
|
rclpy.spin_once(node, timeout_sec=0.2)
|
|
|
|
|
|
def stats(msg):
|
|
if msg is None:
|
|
return None
|
|
pts = [p for p in pc2.read_points(msg, field_names=('x', 'y', 'z'), skip_nans=True)]
|
|
fin = [p for p in pts if all(abs(v) != float('inf') for v in p)]
|
|
if not fin:
|
|
return (0, 0.0, 0.0)
|
|
d = [((p[0] ** 2 + p[1] ** 2) ** 0.5) for p in fin]
|
|
return (len(fin), min(d), max(d))
|
|
|
|
|
|
raw = stats(got.get('raw'))
|
|
flt = stats(got.get('filtered'))
|
|
print(f'原始 /scan/points : {raw[0]} 点, 距离 {raw[1]:.2f} ~ {raw[2]:.2f} m' if raw else '没收到原始点云')
|
|
print(f'自滤 /scan/points_filtered : {flt[0]} 点, 距离 {flt[1]:.2f} ~ {flt[2]:.2f} m' if flt else '没收到自滤点云')
|
|
node.destroy_node()
|
|
rclpy.shutdown()
|