Repository navigation
fix(scene): packet body index cache key misses requested body names - #2567
Merged
Merged
Conversation
_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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
SceneTensorReadPlan._packet_body_indices的缓存键只用了compiled(整个聚合 body 轴),没有包含requested:当两个 entity 从同一个聚合轴里请求不同的 body 子集时(例如一个
robotentity 请求 13 个 body、一个obstaclesmocap entity 请求 6 个 body,二者共享body_pos_w/body_lin_vel_w这个 packed body 字段),第二次调用会命中第一次的缓存,返回第一实体的行索引,导致ray_pose_view拿到错误数量的 body(进而RayScan._refresh_full_pose报 shape mismatch,或静默写错行)。修复
把
requested也纳入缓存键:并同步更新
_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