Skip to content

feat(motrix): 提供 selected-body fused world-state 读取接口 #1305

Description

@TATP-233

Parent roadmap: #1304
Blocks: #1308

一句话问题

MotrixSim 目前只能分别读取/缓存 full-batch link pose 与 velocity,UniLab 为 14 个 tracked bodies 读取 world-state 时仍要跨 Python/Rust 边界并从全 link 数组二次 gather,无法直接实现统一 SimBackend.copy_body_state_w() 的低分配语义。

为什么现在做

  • MotrixBackend._ensure_link_velocity_cache() 会调用 model.get_link_velocities(data) 物化全部 link velocity;pose 与 velocity随后再按 body IDs 选择。
  • perf(profiling): motion tracking update_state/reset_done 逐 term profiling(#1292 杠杆 1) #1293 中 Motrix 的 termination/anchor_pos 首次 robot-state refresh 被归属 9.89 ms,明显高于 MuJoCo/MJWarp。
  • 8192×14 的 UniLab probe 表明,当前 getter + 二次 gather 为 5.153 ms,而 caller-owned direct copy 为 0.718 ms;CPU Numba 无法消除 MotrixSim 内部 full-link 物化与 Rust 边界。

最小交付结果

MotrixSim 发布一个可由 UniLab Motrix backend 消费的 selected-body fused world-state API:一次调用读取指定 numeric link/body IDs 的 position、quaternion、linear velocity、angular velocity,避免为未选择 link 生成 Python 可见数组,并支持一次连续返回或写入 caller-owned 输出。

In scope

  • 输入使用冷路径已解析的 numeric link/body IDs;热路径不做名称/XML 查询。
  • 一次 native 调用返回所选 bodies 的四组 world-frame state,shape 对齐 (num_envs, num_selected, width)。
  • quaternion 顺序、dtype、数组连续性与生命周期有明确 contract。
  • 优先支持 caller-owned out;若 PyO3 限制不适合多 out,允许返回一个 packed contiguous buffer,由 UniLab adapter 做一次拆分。
  • 提供 8192 envs、14 selected bodies 的 full-link getter 对照 microbenchmark。
  • 发布包含该接口的 motrixsim-core 版本,供 refactor(motrix): 接入 fused body-state 接口并删除临时 kernel #1308 升级 pin。

Non-goals

Owner 与预计改动

Acceptance criteria

  • 新版本可对任意合法 selected numeric IDs 一次读取四组 world-state,数值与现有 getters 在明确容差内一致。
  • 8192×14 benchmark 证明不再生成四组 full-link Python 中间数组,且相对现有 getter 路径无回退。
  • UniLab 可仅通过正式 SimBackend.copy_body_state_w() adapter 消费该接口,无 backend 私有能力向 task/env 泄漏。
  • motrixsim-core 新版本及 API 文档可用。

Stop conditions

  • native 侧无法按 selected IDs 缩小计算/物化范围;需回报真实限制后重新决定 packed full-link view 是否仍值得接入。
  • 接口要求 task 名称、asset/XML 元数据或运行时 capability 探测;停止并改写为 backend-owned cold binding。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:motrixMotrixSim related workenhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions