Fix world_id/env_id conflation in NewtonSiteFrameView for the flat builder - #7688
Conversation
…ilder NewtonSiteFrameView._initialize_from_specs indexed NewtonManager._world_xforms directly with a per-environment env_id when resolving a world-attached (body-less) site. The flat (non-replicated, replicate_physics=False) builder has exactly one shared Newton world regardless of environment count, so _world_xforms has length 1 there -- any env_id greater than 0 raised IndexError. Callers hit this whenever a per-environment site with no rigid-body/articulation-root ancestor is resolved under the flat builder, e.g. a streaming/follow camera whose target_prim_path pattern falls back to the per-world site path. Fall back to the single shared world when only one exists, matching the same "flat builder has fewer per-thing entries than per-env" pattern already fixed for site injection and articulation bindings. Adds a regression test reproducing the crash with replicate_physics=False and a per-env world-attached prim.
There was a problem hiding this comment.
Isaac Lab Review Bot
The single-world fallback prevents the flat-builder IndexError, but it collapses per-environment world-attached frames onto the same transform, producing incorrect world poses when environment origins differ.
- Design and architecture: Handling the flat builder inside
NewtonSiteFrameViewis appropriately localized, but mapping every environment to_world_xforms[0]does not preserve the replicated path’s environment-to-world transform semantics. The flat path must retain each environment’s origin when resolving world-attached sites. - API: No public signatures or result shapes change, and the changelog fragment is present. However,
FrameView.get_world_poses()can now return identical, incorrect world-space poses for distinct environments, so the behavioral contract is not correctly restored. - Implementation: At line 450, all
env_idsuse the same_world_xforms[0]when only one Newton world exists. Because the same site-localxformis then composed for each entry, environment-root offsets are lost. The regression test reinforces this collapse by expecting identical positions despite configuring multiple environments with nonzero spacing; the implementation and test should instead account for each environment’s origin transform.
Significant concerns. Posted 1 actionable finding inline.
Automated review; human maintainers own approval decisions.
| # regardless of environment count, so env-indexed callers (env_ids | ||
| # from a per-environment site spec) must fall back to that single | ||
| # world instead of indexing world_id (an env index) out of bounds. | ||
| world_xform = NewtonManager._world_xforms[world_id if num_worlds > 1 else 0] |
There was a problem hiding this comment.
🟡 Warning · Implementation — Flat-builder fallback collapses per-env world poses
In the replicated path xform is env-relative and world_xform supplies the environment offset. With num_worlds == 1, every world_id in env_ids now composes the same _world_xforms[0] with the same xform, so all environments report an identical world pose and env-root offsets are silently lost (e.g. a follow camera tracking env 0's location for every env). Compose each environment's origin transform in the flat case instead of reusing world 0.
Description
NewtonSiteFrameView._initialize_from_specsresolves world-attached (body-less)sites by indexing
NewtonManager._world_xformsdirectly with a per-environmentenv_id. The flat (non-replicated,replicate_physics=False) builder hasexactly one shared Newton world regardless of environment count, so
_world_xformshas length 1 there — anyenv_idgreater than 0 raisesIndexError: list index out of range.This is hit whenever a per-environment site with no rigid-body/articulation-root
ancestor is resolved under the flat builder — for example a streaming/follow
camera (
streaming_cam_target_prim_path) whose target pattern falls back to theper-world site path because the target prim itself isn't a rigid body.
The fix falls back to the single shared world when
_world_xformshas only oneentry, matching the same "flat builder has fewer per-thing entries than
per-env" pattern already fixed for site injection (#7672) and articulation
bindings (#7673).
Fixes # (no tracked issue — found while wiring up a Newton follow-camera for a
downstream policy-recording script)
Type of change
Release backport
developChecklist
pre-commitchecks (ruff check/ruff format)source/isaaclab_newton/changelog.d/CONTRIBUTORS.md(already present)