IB-Robot semantic_mapping 实战指南:基于 D435 RGB-D 的持久化 3D 语义目标地图构建、查询与 Nav2 停靠位解析

原创2026-10-14 13:32:101,436 阅读
文章标签:人工智能具身智能机器人AI Agent模型推理服务多模态计算机视觉语音本地部署

IB-Robot semantic_mapping 实战指南:基于 D435 RGB-D 的持久化 3D 语义目标地图构建、查询与 Nav2 停靠位解析

导读

semantic_mapping 是 openEuler IB-Robot 中负责构建独立、持久化的 3D 语义目标地图的 ROS 2 功能包:它读取固定安装在底盘上的 D435(RealSense)同步 RGB-D 数据,以开放词汇(open-vocabulary)感知流水线识别环境中的目标物体,并只依赖时间戳对应的 TF,不依赖 FAST-LIO、FAST-LIVO2 或其他 SLAM 的内部地图表示。读完本文,你将掌握从「RGB-D + LiDAR 联合数据采集」到「离线语义建图」「在线实时融合」「结构化/文本查询」再到「Nav2 停靠位(stand-off)目标解析」的完整链路,并理解其 SLAM handoff、Workflow Readiness 门控、模型资产与一致性(conformance)验收机制。

一个功能包、三种工作阶段:不要把"建图"混为一谈

该功能包刻意区分三个阶段,避免把导航几何建图和语义对象建图混成同一个 mapping 概念:

阶段 入口 产物 / 职责
Capture robot_config:=lekiwi_semantic_capture 同步采集 MID-360、D435i、TF 和标定证据,同时保存并提升导航二维地图
Offline mapping offline_mapping.launch.py 从 capture bag 构建或更新持久化 3D 语义对象数据库
Online mapping / query semantic_mapping.launch.py 对实时 RGB-D 做语义对象更新,并提供查询和目标解析接口

三个阶段各自拥有独立 launch 入口,且都不会启动 embodied runtime(在线入口按 role list 启动所有 enabled、referenced generic model services;离线入口只启动 SAM2、RAM++ 和 SigLIP2 image construction services)。入口实现见 launch/semantic_mapping.launch.py 与 launch/offline_mapping.launch.py:它们都把同一个正 63-bit configuration_generation 和 require_semantic_identity=true 传给 generic model hosts,并把 generation 及 manifest semantic identities 传给 mapping 节点。

RGB-D LiDAR 数据采集(Capture)

联合采集使用独立 capture profile lekiwi_semantic_capture(配置见 src/robot_config/config/robots/lekiwi_semantic_capture.yaml)。开始前必须已批准 D435i/MID-360 标定,确保 ~/.ros/ibrobot/calib/current/base_to_front_camera.yaml 存在且状态为 approved。

采集命令与拓扑

开发板终端 A 启动采集主链,并在保存结束前保持运行:

ros2 launch robot_config robot.launch.py \
  robot_config:=lekiwi_semantic_capture

该 profile 直接启用 MID-360、FAST-LIO、slam_toolbox、D435i 和 continuous MCAP 录制,不需要额外选择 navigation stage 或录制开关,也不支持 episodic 录制。从配置可看到它显式启用了 fast_lio.enabled: true、slam_toolbox.enabled: true 与 recording.semantic_dataset: true,并固定了 17 个录制 topic(LiDAR、IMU、raw/filtered odometry、registered cloud、scan、map、wheel/odom、cmd_vel、RGB、raw/aligned depth、三路 CameraInfo、/tf 与 /tf_static)。

开发板终端 B 使用键盘遥控完成建图轨迹:

ros2 run teleop_twist_keyboard teleop_twist_keyboard

在同一 ROS domain 的 PC 端启动低带宽 RViz 预览(launch 实现见 lekiwi_semantic_capture_rviz.launch.py):

ros2 launch semantic_mapping lekiwi_semantic_capture_rviz.launch.py

开发板在本地将 RealSense RGB 压缩为 8 FPS、JPEG quality 70,并将 MID-360 registered cloud 限制为每帧 6000 点。PC 侧 RViz 使用 /semantic_mapping/preview/* 观察低带宽图像和点云,同时订阅 /map、/scan、TF 和 robot description;它不订阅 raw RGB、depth 或完整 registered cloud。

保存命令与归档校验

完成同一条建图轨迹后,在 launch 仍运行时执行一个保存命令:

ros2 run semantic_mapping save_semantic_map

该命令(实现见 semantic_mapping/dataset_capture.py)依次:

  1. 停止 recorder;
  2. 保存当前 slam_toolbox 地图;
  3. 执行 MCAP reindex;
  4. 生成标定快照和根目录元数据;
  5. 校验 SHA256SUMS 与离线 RGB-D / 历史 TF;
  6. 以 gzip level 1 流式创建同名 .tar.gz(不先生成同尺寸临时 .tar);
  7. 归档和离线校验都成功后,才将同一 YAML/PGM 地图成对、失败可回滚地提升到 ~/.ros/ibrobot/maps/map.yaml 和 map.pgm。

任一步失败都会返回非零状态。recorder 在 rosbag 启动前固定 MID-360 mount YAML 和当时存在的 approved camera artifact 字节与 SHA-256;finalizer 只读取这些 pinned bytes,不会重新读取可能已被替换的 current/ 源文件。camera artifact 缺失时仍生成 bag、manifest、checksum 和压缩归档,但状态明确为 calibration_incomplete,且该 profile 不发布零值 base_link -> camera 替代 TF。

默认输出目录和归档为:

~/.ros/ibrobot/semantic_mapping/lekiwi_semantic_capture_<timestamp>/
~/.ros/ibrobot/semantic_mapping/lekiwi_semantic_capture_<timestamp>.tar.gz

当前 session handoff 保存在 ~/.ros/ibrobot/semantic_mapping/current.json。session 目录包含:

bag/*.mcap
bag/metadata.yaml
bag/calibration_snapshot.json
map/map.yaml
map/map.pgm
manifest.json
SHA256SUMS
README.md

默认导航地图只有在 checksum 和离线几何校验成功后才会更新;promotion 失败时 session handoff 状态为 navigation_map_promotion_failed,原有默认地图保持不变。

20 秒静止烟测

烟测只验证工程闭环,不评价地图质量:

# Terminal A: leave this launch running for the map save service.
ros2 launch robot_config robot.launch.py \
  robot_config:=lekiwi_semantic_capture

# Terminal B: wait about 20 seconds, then save and validate everything.
sleep 20
ros2 run semantic_mapping save_semantic_map

如果静止场景无法产生可保存地图,应保持 launch 运行并在 slam_toolbox 保存服务成功后再执行同一收尾命令;收尾流程只验证地图文件存在,不评价地图覆盖质量。烟测不运行任何语义模型。

reindex 后的 metadata.yaml 是 topic/type/count 的唯一事实源(对应校验逻辑见 dataset_capture.py 的 validate_mcap_metadata)。LiDAR、IMU、FAST-LIO raw/filtered odometry、registered cloud、scan、map、RGB、raw/aligned depth、三路 CameraInfo、/tf 和 /tf_static 必须类型匹配且非零。当前 capture profile 禁止 cmd bridge 发布另一套 wheel odometry,且 20 秒静止烟测可以没有操作员命令,因此 /wheel/odom 和 /cmd_vel 只做 reported/optional,不会造成无害的静止烟测失败;/diagnostics 不录制也不检查。metadata 有 per-file 时间时,顶层 start/duration 必须覆盖所有 split;旧 Humble metadata 没有 per-file 时间时只记录 coverage unavailable。

保存命令在同一个同步 RGB 时间戳验证 map -> camera frame 和 map -> base_link。若 snapshot 为 calibration_incomplete,数据产物仍会保留用于诊断,但保存命令返回失败,不把它报告为可用语义地图。

Data Flow:从同步 RGB-D 到持久化目标

在线与离线建图共享同一套数据处理逻辑,核心 9 步(在线路径见 semantic_mapping_node.py,服务编排见 service_pipeline.py):

  1. 使用 ApproximateTimeSynchronizer 同步彩色图、对齐深度图和 CameraInfo(queue_size 与 slop 分别由 sync_queue_size、sync_slop_sec 控制);
  2. 默认通过服务并发运行 SAM2 盲扫和 RAM++ 打标,再批量调用 SigLIP2 为各 mask 生成视觉特征(ServiceFramePipeline 用 call_async 组合 ROS futures,不阻塞 executor 线程);
  3. 将 mask 内有效深度像素反投影至相机光学坐标系,并过滤深度离群点(project_masked_depth);
  4. 按 RGB 图像时间戳查询 global_frame -> camera optical frame TF;
  5. 将物体点云、中心点和世界坐标轴包围盒转换至 global_frame(transform_geometry);
  6. 最终类别由 RAM++ 决定:服务端先应用颜色过滤和 SSOT 场景排除列表,再返回 top-5 候选,建图选择最高分局部标签;没有局部候选时标记为 unlabeled,不回退到全图场景标签(select_ram_label 低于 min_confidence 时返回 unlabeled);
  7. 使用类别、世界坐标距离和 SigLIP 余弦相似度关联持久目标(SemanticTracker);SigLIP 不覆盖 RAM++ 标签;
  8. 将目标状态和 SigLIP 特征写入独立 SQLite 数据库(见 database.py,包含 semantic_manifest、mapping_runs、semantic_objects、semantic_observations、semantic_captions、object_geometry 等表);
  9. 可选的 label_refinement 对 unlabeled、低置信或场景排除类别选择代表视图,异步调用外部云端 VLM 返回严格 JSON 标签;失败时保留 RAM++ 标签,成功时记录模型、候选、旧标签和时间 provenance。

在关联阶段,SemanticTracker 采用位置加权融合:position_weight(默认 0.55)权衡世界坐标距离与 SigLIP 余弦相似度(阈值默认 0.72),并受 association_distance_m(0.45 m)与 association_max_size_ratio(4.0)约束;每次新观测以 alpha = 1 / min(observation_count + 1, 5) 平滑位置与尺寸(见 association.py)。

Public Interfaces:发布、查询与目标解析

Topic 与 Service

Interface Default Description
Topic /semantic_mapping/objects SemanticObject3DArray 持久目标快照,Reliable + Transient Local
Topic /semantic_mapping/object_cloud 当前处理帧中所有实例的世界坐标点云
Service /semantic_mapping/get_objects 按 ID、类别、文本、状态、新鲜度和空间区域查询目标
Service /semantic_mapping/resolve_target 返回相互区分的目标物体姿态和 Nav2 stand-off 姿态

其中查询服务请求/响应定义见 ibrobot_msgs/srv/GetSemanticObjects.srv,目标解析服务定义见 ibrobot_msgs/srv/ResolveSemanticTarget.srv。节点默认使用 MultiThreadedExecutor(num_threads=4) 运行,并在主循环中捕获单个 client 异常继续服务(见 semantic_mapping_node.py 的 main)。

数据库默认位于 ~/.ros/ibrobot/semantic_map.sqlite3,不保存 SLAM 几何点云或 SLAM 状态。

resolve_target:面向当前机器人一侧的停靠候选

resolve_target 使用 live TF global_frame -> base_frame(默认 map -> base_link)选择机器人当前所在一侧的停靠候选,并让最终 yaw 指向目标物体;TF 不可用时 fail closed,不会回退到 map 原点或静态机器人坐标参数。候选生成见 target_resolution.py:默认以机器人指向目标的方位角为首选,再生成 16 个环形候选并依次交给 checker 做可达性筛选。

命令行调用示例:

ros2 service call /semantic_mapping/resolve_target \
  ibrobot_msgs/srv/ResolveSemanticTarget \
  "{query_text: banana, stand_off_distance_m: 0.5, require_manipulation_ready: false}"

多个同名人工轨迹匹配时返回明确的歧义错误,要求提供 object_id(源码中 _target_callback 在 len(matches) > 1 时返回 "provide object_id for a unique target")。

semantic_map_standoff:紧凑停靠位工具

静态地图使用者可以通过 semantic_map_standoff 查询人工标注物品并输出紧凑的 <a href="https://link.gitcode.com/i/ba420b1fef4ebaeeca18529b8779786d" target="_blank">x, y, theta_degrees] 停靠位(实现见 [standoff_query.py,入口注册于 setup.py)。该工具只查询 get_objects,不依赖 TF 或 live readiness;默认以 map 原点作为接近参考点,也可以传入一个 map-frame 参考点:

source .shrc_local
export ROS_DOMAIN_ID=77
ros2 run semantic_mapping semantic_map_standoff banana 0.2
# [0.6536,-0.9555,-55.6]

ros2 run semantic_mapping semantic_map_standoff banana 0.2 \
  --reference-x 0.24 --reference-y 0.09

输出角度以度为单位,0 表示 map-frame 的 x 正轴,正方向为逆时针。查询失败时输出 []。该工具只生成几何目标,不替代 Nav2 的可达性和安全门控。

Configuration:从 robot_config SSOT 到节点参数

新流水线配置由 robot_config YAML 顶层的 robot.semantic_mapping 管理,不依赖 embodied minimal closure。完整样例见 src/robot_config/config/robots/lekiwi_realsense_mapping.yaml,参数翻译逻辑见 semantic_mapping/configuration.py 的 semantic_mapping_parameters。launch 会校验 robot.semantic_mapping.enabled 必须为 true,否则直接抛错。

相机引用必须指向一个启用 aligned depth、固定安装并具有 base_link 静态变换的 RealSense peripheral:

semantic_mapping:
  enabled: true
  camera:
    peripheral: realsense
    mounting: fixed
    parent_frame: base_link
    rgb_topic: /camera/realsense/image_raw
    depth_topic: /camera/realsense/aligned_depth_to_color/image_raw
    camera_info_topic: /camera/realsense/camera_info
  slam:
    global_frame: map
    active_map_hash_topic: /slam/active_geometry_map_hash
    localization_ready_topic: /slam/localization_ready
    authoritative_map_odom_topic: /slam/authoritative_map_odom_ready
    geometry_map_hash: <active-map-hash>
    localization_session_id: <active-session-id>
    calibration_id: <d435-calibration-hash>
    urdf_hash: <active-urdf-hash>
    map_odom_authority: slam
  perception:
    mapping_backend: service
    semantic_roles:
      sam2_masks: semantic_sam2_masks
      ram_plus_tags: semantic_ram_plus_tags
      siglip2_image: semantic_siglip2_image
      siglip2_text: semantic_siglip2_text
      gdino_confirmation: semantic_gdino_confirmation

模型服务的唯一配置源:顶层 perception_services

完整配置包含 persistence、mask/depth filtering、bounded queue/batch、lifecycle、labels、target-watch 和 public interface 参数。模型 endpoint 的唯一配置源是顶层 perception_services.services;每个 role 指向一个 enabled service ID,不再直接配置 backend、endpoint 或模型 identity。service 模式下 loader 从 schema-v3 bundle manifest 取得 semantic identity,验证精确 service type 和 required/optional policy,并拒绝 SigLIP2 image/text embedding metadata 不兼容的配置。检查入库的 service entries 是 disabled templates,因此没有 production model assets 时 YAML 仍可加载;启用建图时必须提供有效 bundle 和 named deployment。role 到模型节点的映射由 robot_config/robot_config/launch_builders/perception_models.py 的 generate_perception_model_nodes 完成——每个 enabled service 生成一个 model_service_node,并传入 configuration_generation 与 require_semantic_identity=true。

filtering:map-frame 地面物体过滤

filtering 默认启用 map-frame 地面物体过滤。节点使用地面支撑的 base_link TF 高度和水平位置作为每帧参考,只保留底部接近地面、顶部高度、水平 footprint 和本体距离在配置范围内的几何体,以排除天花板、墙面、远处物体和覆盖整片地面的 mask(几何判定见 geometry.py 的 is_ground_object)。service backend 在 SAM2 后、局部 RAM++ 和 SigLIP2 前执行该筛选,减少后续模型计算;其他底盘可通过 reference frame 和 offset 校准地面高度:

filtering:
  ground_filter_enabled: true
  ground_reference_frame: base_link
  ground_height_offset_m: 0.0
  ground_max_bottom_clearance_m: 0.15
  ground_max_object_height_m: 0.75
  ground_max_footprint_m: 1.2
  max_object_distance_m: 2.5

realsense_mapping 配置还补充了 max_object_extent_m: 0.65(3D AABB 边限,用于拒绝场景级 SAM mask)、depth_trunc_m: 4.0、min_points: 30、min_mask_pixels: 300、min_mask_area_ratio: 0.001、min_mask_valid_depth_ratio: 0.2、max_mask_overlap_ratio: 0.8 等 mask/depth 过滤参数。

labels:基础标签策略

labels 是基础标签策略,不依赖云端复核是否启用。excluded_labels 在 RAM++ 服务截断候选前应用,min_confidence 决定局部标签是否降级为 unlabeled,max_candidates_per_mask 控制每个 mask 返回的候选数量:

labels:
  min_confidence: 0.2
  max_candidates_per_mask: 5
  excluded_labels: [sky, traffic light, food, fruit, container]

完整模板在 lekiwi_realsense_mapping.yaml 中列出 60+ 个排除项(场景背景、通用概念、形状、动作类 RAM++ 噪声),如 animal、person、building、floor、room、shape、cube、stop sign、unlabeled 等。此外 labels 还支持 recurrence_count_ratio、high_confidence_override_margin 与 allowed_labels(alias 白名单,由 parse_label_aliases 校验映射唯一性)。

label_refinement:云端 VLM 复核

云端标签复核默认关闭,不是建图或查询 readiness gate。在线请求由独立 worker 执行,不阻塞 ROS executor;离线请求在帧融合结束后执行。基础 labels.excluded_labels 同时作为复核触发和响应禁止列表,低置信标签由 trigger_below_confidence 触发:

label_refinement:
  enabled: false
  model: gpt-5.6-sol
  model_identity: xunxing/gpt-5.6-sol@az.gptplus5.com
  prompt: <complete scene-specific review instructions>
  min_confidence: 0.8
  trigger_below_confidence: 0.7
  min_observations: 1

启用前需按 src/embodied_common/vlm_models.yaml 配置多模态模型并设置对应 API key 环境变量。例如当前 gpt-5.6-sol 的 Xunxing 路由使用 XUNXING_API_KEY;key 只允许通过环境变量提供,禁止写入 YAML。外部模型必须仅返回 label 和 confidence 两个 JSON 字段;candidate_match 由节点根据实际候选本地推导。worker 使用有界队列(maxsize=32)与代表视图(RepresentativeViewStore),成功/失败分别通过 apply_refinement / record_refinement_rejection 落库。

在线与离线启动方式

在线入口按 role list 启动所有 enabled、referenced generic model services;离线入口只启动 SAM2、RAM++ 和 SigLIP2 image construction services(_CONSTRUCTION_ROLES)。

source .shrc_local
export ROS_DOMAIN_ID=42
ros2 launch semantic_mapping semantic_mapping.launch.py \
  config_path:=/path/to/enabled-lekiwi-mapping.yaml

mode:=query_only 只启动 semantic_mapping_node,不启动 SAM2/RAM++/SigLIP2 模型服务;用于在导航板上加载预建静态语义地图并提供 get_objects 和 resolve_target 查询:

source .shrc_local
export ROS_DOMAIN_ID=42
ros2 launch semantic_mapping semantic_mapping.launch.py \
  mode:=query_only \
  config_path:=/path/to/enabled-lekiwi-mapping.yaml \
  database_path:=/data/semantic_map.sqlite3 \
  artifact_output_dir:=/data/artifacts

query_only 模式下 online_processing_enabled=false,节点不创建同步器、帧队列与感知 client,仅加载 SQLite 数据库并暴露查询/解析服务(launch 代码在 semantic_mapping.launch.py 中明确区分)。

离线入口额外要求 rosbag 路径;它从同一配置读取 camera topics、map/model identities、filtering 和 services:

source .shrc_local
export ROS_DOMAIN_ID=42
ros2 launch semantic_mapping offline_mapping.launch.py \
  config_path:=/path/to/enabled-lekiwi-mapping.yaml \
  bag_path:=/path/to/rosbag \
  max_frames:=100 frame_sampling:=uniform

frame_sampling:=uniform 在全部可用 RGB-D/TF 帧中均匀选择 max_frames,而默认 sequential 从开头连续处理。诊断指定时段时可使用 start_frame 跳过对应数量的可用帧(参数定义见 offline_mapping.launch.py,处理完成后自动 Shutdown)。

queue:有界队列与批处理

每帧候选总量和模型单批上限分别由 queue.max_masks_per_frame 与 queue.max_masks_per_batch 控制。默认保留 32 个 SAM2 候选,并由流水线拆成最多 8 个 mask 的 RAM++/SigLIP2 请求(split_batches 在 1..MAX_MASK_BATCH 之间强制校验),以提高地面小目标召回而不突破模型 ABI。同步与帧队列参数包括 sync_queue_size: 10、sync_slop_sec: 0.06、tf_timeout_sec: 0.15、processing_interval_sec: 0.5、frame_capacity: 2、policy: drop_oldest。

旧 embedded 路径(仅迁移兼容)

旧 embedded mapping 路径仍支持 Hugging Face 格式的本地 Grounding DINO,但只用于显式迁移兼容:

detector_backend: huggingface
grounding_model_path: /data/Research/3D_semantic/models/grounding-dino-tiny
sam_checkpoint: /data/Research/3D_semantic/Grounded-SAM-2/checkpoints/sam2.1_hiera_large.pt
sam_config: configs/sam2.1/sam2.1_hiera_l.yaml
siglip_model_path: siglip2_so400m_patch14_384/assets/model

抓取和语义建图都通过顶层 perception_services.services 使用 named deployment。抓取使用显式图像的 GroundingDetect / SegmentDetections,语义建图使用 construction 和 text roles;两者不共享隐式快照节点。若显式选择 embedded mapping,必须设置 allow_legacy_embedded: true。embedded 启动不会解析或启动 generic service bundles,也不要求 service semantic identities;service 模式仍严格要求 construction 和 text roles。

global_frame 必须是 SLAM 提供的持久固定坐标系。FAST-LIO 可使用 camera_init;若后续 SLAM 发布标准 map 坐标系,只需修改该参数。

Model Assets:schema-v3 bundle 与受控 runtime

./scripts/setup.sh
./scripts/download_perception_models.sh

下载脚本默认准备 semantic mapping 的四个 schema-v3 bundle:

models/
├── _work/<bundle>/candidates/          # 转换中间产物,可随时归档/删除
├── sam2.1_hiera_tiny/{inference_manifest.json,assets/}
├── ram_plus_swin_large_14m/{inference_manifest.json,assets/}
├── siglip2_so400m_patch14_384/{inference_manifest.json,assets/}
└── grounded_sam2_swint_ogc/{inference_manifest.json,assets/}

RAM++ runtime 由 third_party/wheels/recognize-anything/ 中受控的 ibrobot-ram wheel 提供;Grounding-DINO runtime 由 third_party/wheels/groundingdino/ 中受控的 ibrobot-groundingdino 纯 Python wheel 提供;源码与权重分开管理。models/_work/ 下的转换产物不是 production deployment,也不属于任何 bundle。只有 manifest 声明并通过对应 conformance 的 named deployment 才能在 production SSOT 中启用。

映射清单使用各服务响应中经过规范化校验的 ModelRuntimeInfo.semantic_identity_json,SigLIP2 图像与文本查询还必须具有相同的 embedding_space_id、维度、归一化和双端预处理契约。backend、named deployment、deployment fingerprint 和 runtime version 仅作为 run/observation provenance 持久化,不参与地图兼容性判断。运行时模型均从本地目录加载;缺少资产、semantic identity 不匹配或 backend 未就绪时服务保持 not-ready,mapping 不会静默回退到其他模型。

SLAM Handoff:消费 SLAM 但不拥有 SLAM

语义地图消费 SLAM 输出,但不拥有 SLAM lifecycle 或 occupancy grid。启动在线 fusion/target resolution 前必须满足:

  • slam.global_frame 是持久全局坐标系,且由唯一 SLAM authority 发布 map -> odom;
  • geometry_map_id 和 geometry_map_hash 对应当前导航几何地图;active hash 必须与数据库 manifest 一致;
  • localization session 已 ready,并能按 RGB timestamp 查询 global frame 到 D435 optical frame 的 TF;
  • cloud_map_topic 已发布非空、同一 map identity 的点云;
  • Nav2 footprint、obstacle map 和 reachability checker ready 后才允许生成 stand-off target。

任一条件不满足时 fusion/target resolution fail closed。离线 export 只生成 semantic manifest、object database 和 object-cloud artifacts,不生成或覆盖 map.pgm、Nav2 map YAML 或 SLAM database。standalone launch 不启动或管理 SLAM,也没有伪造 readiness 的默认值。外部集成必须在配置指定的 transient-local topics 发布 active map hash,以及 localization、authoritative map-to-odom、footprint、obstacle map 和 reachability Bool 证据;cloud map 和 timestamped TF 仍从其原生数据流取得。任何证据尚未发布时默认保持 fail closed。

节点侧通过 evaluate_slam_readiness 聚合这些证据(见 slam_readiness.py),同时订阅 /slam/active_geometry_map_hash、/slam/localization_ready、/slam/authoritative_map_odom_ready、/navigation/footprint_ready、/navigation/obstacle_map_ready、/navigation/reachability_ready 等 transient-local 信号(topic 声明见 semantic_mapping_node.py 的参数默认表)。

Workflow Readiness Contract:按工作流独立评估

semantic_mapping.workflow_readiness evaluates each workflow independently and returns a WorkflowReadiness value containing all gate evidence, failed reasons, and the aggregate ready property(纯 Python 值对象实现见 workflow_readiness.py)。它不暴露一个进程级 readiness 布尔值,也不把 captioning 设为 gate。

Workflow Required gates
Offline map construction Ready, compatible SAM2, RAM++, and SigLIP2 image; aligned RGB-D/CameraInfo; timestamped TF; localization input
Online map construction Offline gates plus compatible active map identity, localization, authoritative map -> odom, /cloud_map, and queue/write admission
Structured query Readable, compatible semantic database; no inference service
Text query Structured-query gates plus ready SigLIP2 text with an embedding space compatible with stored image embeddings
Navigation staging Action-admissible object, compatible active map, localization, timestamped TF, authoritative map -> odom, footprint, obstacle map, and reachability
Manipulation confirmation Navigation and fresh-object admission plus ready Grounding DINO and confirmation SAM2
Read-only diagnostics Database successfully opened in diagnostic mode; no inference service

Existing ROS responses carry applicable failures through SemanticMapMetadata.readiness_reason 和 message(消息定义见 ibrobot_msgs/msg/SemanticMapMetadata.msg,节点侧由 _metadata_message 填充)。Text queries fail independently when text inference or embedding compatibility is unavailable。当前接口没有 request timestamp,也没有 fresh Grounding DINO + SAM2 confirmation result/diagnostic,因此 manipulation readiness 必须 fail closed,并明确报告 fresh manipulation confirmation has not run;service discovery 不作为模型 ready 证据。导航只能复用最近一次 fusion 时按图像时间戳成功查询的 TF 证据,在尚无该证据时 fail closed;当前 target request 不携带时间戳,因此该证据只证明现有地图观测链路,不能声明请求时刻的新鲜 TF。No new ROS readiness message is defined; callers needing every evidence item can use the pure-Python value object.

Conformance And Timing:逐阶段验收而非混合指标

固定 D435 fixture 的 backend-neutral reference 位于 src/perception_service/test/fixtures/realsense_rgbd_frame/conformance_reference.json。conformance 分别比较 mask count/IoU、embedding cosine、label top-1/score delta、3D centroid/extent 和 failure semantics,不使用一个混合 end-to-end IoU 掩盖不同 stage 的偏差。

性能报告按 backend 和 mask batch size 分组,并分别记录 inference、serialization、queue wait、service round trip、fusion commit 和 end-to-end 的 P50/P95,同时报告 throughput 和 dropped frames。model-only timing 不能作为 end-to-end latency;没有样本的报告以 0 和 processed_frames=0 明确表示,不作为 promotion evidence。

初始 production promotion gate 要求:

  • 至少 100 个 timing samples;
  • mask batch 不超过 8;
  • model inference P50 不超过 326 ms;
  • 在线模式:end-to-end P95 ≤ 750 ms、queue-wait P95 ≤ 100 ms、drop ratio ≤ 5%;
  • 离线模式:throughput ≥ 1 frame/s;
  • 所有 stage-specific conformance 必须先通过。

阈值是初始软件 gate,必须在目标硬件上记录实际报告后才能 promotion;当前未验证的 Ascend deployment 仍保持 not-ready。

无需 ROS 或真实设备,可在 IB-Robot 仓库根目录使用 RealSense RGB-D fixture 运行模型验证:

source .shrc_local
python3 src/semantic_mapping/scripts/verify_rgbd_fixture.py \
  --fixture src/perception_service/test/fixtures/realsense_rgbd_frame \
  --grounding-model <grounding-dino-model-path> \
  --sam-checkpoint <sam2-checkpoint-path> \
  --siglip-model <siglip2-model-path>

安装感知依赖后,也可验证 ROS 2 节点的同步订阅、TF、持久化和查询服务。先启动节点:

source .shrc_local
ros2 run semantic_mapping semantic_mapping_node --ros-args \
  -p detector_backend:=huggingface \
  -p grounding_model_path:=/data/Research/3D_semantic/models/grounding-dino-tiny \
  -p sam_checkpoint:=/data/Research/3D_semantic/Grounded-SAM-2/checkpoints/sam2.1_hiera_large.pt \
  -p sam_config:=configs/sam2.1/sam2.1_hiera_l.yaml \
  -p siglip_model_path:=models/siglip2_so400m_patch14_384/assets/model

再从另一个终端发布 fixture 并等待查询结果:

source .shrc_local
python src/semantic_mapping/scripts/publish_rgbd_fixture.py \
  --fixture src/perception_service/test/fixtures/realsense_rgbd_frame

librealsense 设备 bag 应通过 realsense2_camera 的 rosbag_filename 参数回放。输入语义节点前必须确认 aligned_depth_to_color/image_raw 实际发布消息;仅出现在 ros2 topic list 中并不表示对齐滤镜已产生数据。

Constraints:硬性输入前提

  • 深度图必须已经对齐到彩色图,且二者分辨率一致;
  • 相机内参必须对应彩色图像素平面;
  • TF 必须能按 RGB 图像时间戳查询,节点不会回退到"最新 TF";
  • 当前姿态表示目标中心点和世界坐标轴包围盒,不估计物体自身旋转;
  • 关联假定目标在短时间内近似静止;被移动的物体可能在超过距离门限后生成新 ID。

从实现看,_depth_scale 会按编码区分 32FC1/64FC1(1.0)与 16-bit 深度(1000.0),prepare_frame 还会校验 RGB/depth/CameraInfo 三路时间戳偏差在 sync_slop_sec 之内——任何不满足上述前提的帧都会在入口被拒绝。

Local Verification Evidence:无开发板的可复现验证

以下检查不依赖开发板即可复现:

source .shrc_local && PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 pytest -q \
  src/perception_service/test src/semantic_mapping/test
source .shrc_local && ./scripts/build.sh --clean
openspec validate redesign-3d-semantic-mapping --strict

当前本地结果为 148 passing tests、clean workspace 构建成功、严格 OpenSpec 校验通过。本地测试套件同时验证:SAM2、SigLIP2 和 Grounding DINO OM adapters 在 production contracts 未 finalize 时会带显式 ABI 或 artifact diagnostics fail closed(对应测试见 src/semantic_mapping/test/ 下的 test_service_pipeline.py、test_online_fault_injection.py、test_slam_readiness.py、test_workflow_readiness.py 等)。

Migration evidence 由 semantic_mapping.migration_evidence 表示(实现见 migration_evidence.py)。它分离 local gates 与 board-only gates,并且在硬件 conformance 与 timing evidence 出现之前拒绝 production-default 切换。没有任何本地测试声称开发板 ACL 执行、OM 数值一致性或生产延迟指标——这些必须由目标硬件上的实际报告支撑。

登录后查看全文
IB_Robot