Skip to content

fix(scene): packet body index cache key misses requested body names - #2567

Merged
TATP-233 merged 1 commit into
mainfrom
fix/ray-pose-body-index-cache-key
Oct 31, 2026
Merged

TATP-233 merged 1 commit into
mainfrom
fix/ray-pose-body-index-cache-key

Conversation

@TATP-233

Copy link
Copy Markdown
Collaborator

问题

SceneTensorReadPlan._packet_body_indices 的缓存键只用了 compiled(整个聚合 body 轴),没有包含 requested:

key = ("body", compiled)

当两个 entity 从同一个聚合轴里请求不同的 body 子集时(例如一个 robot entity 请求 13 个 body、一个 obstacles mocap entity 请求 6 个 body,二者共享 body_pos_w/body_lin_vel_w 这个 packed body 字段),第二次调用会命中第一次的缓存,返回第一实体的行索引,导致 ray_pose_view 拿到错误数量的 body(进而 RayScan._refresh_full_pose 报 shape mismatch,或静默写错行)。

修复

把 requested 也纳入缓存键:

key = ("body", tuple(requested), compiled)

并同步更新 _packet_body_index_cache 的类型注解为 dict[tuple[str, tuple[str, ...], tuple[str, ...]], torch.Tensor]。

复现

构造一个含 robot(13 body)+ obstacles(6 mocap body)两个 entity 的 Manager 场景,给 obstacles 走 RayScan 位姿同步(mjwarp 后端),在 read_plan.refresh() 后按序调用 ray_pose_view("robot", ...) 与 ray_pose_view("obstacles", ...),后者会返回 13 个 body 而非 6 个。

🤖 Generated with Claude Code

_packet_body_indices cached by `compiled` (the full aggregate body axis)
alone, so two entities requesting different subsets of the same axis (e.g.
a robot and a mocap-obstacle entity) returned the first entity's row indices
for the second. Include `requested` in the cache key.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@TATP-233
TATP-233 merged commit 849c5da into main Oct 31, 2026
12 checks passed
@TATP-233
TATP-233 deleted the fix/ray-pose-body-index-cache-key branch October 31, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant