Skip to content

Fix world_id/env_id conflation in NewtonSiteFrameView for the flat builder - #7688

Open
pascal-roth wants to merge 1 commit into
isaac-sim:developfrom
pascal-roth:fix/newton-frameview-flat-builder-world-index
Open

Fix world_id/env_id conflation in NewtonSiteFrameView for the flat builder#7688
pascal-roth wants to merge 1 commit into
isaac-sim:developfrom
pascal-roth:fix/newton-frameview-flat-builder-world-index

Conversation

@pascal-roth

Copy link
Copy Markdown
Collaborator

Description

NewtonSiteFrameView._initialize_from_specs resolves world-attached (body-less)
sites by indexing NewtonManager._world_xforms directly with a per-environment
env_id. 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 raises
IndexError: 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 the
per-world site path because the target prim itself isn't a rigid body.

File ".../isaaclab_newton/sim/views/newton_site_frame_view.py", line 431, in _initialize_from_specs
    world_xform = NewtonManager._world_xforms[world_id]
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
IndexError: list index out of range

The fix falls back to the single shared world when _world_xforms has only one
entry, 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

  • Bug fix (non-breaking change which fixes an issue)

Release backport

  • Backport this pull request to the active release branch after it merges into develop

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks (ruff check / ruff format)
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective (verified failing without the fix, passing with it)
  • I have added a changelog fragment under source/isaaclab_newton/changelog.d/
  • I have added my name to CONTRIBUTORS.md (already present)

…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.
@pascal-roth
pascal-roth requested a review from a team September 9, 2026 17:42
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Sep 9, 2026
@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; the fallback is limited to the single-world configuration and the original failure path is covered by a regression test.

Summary

  • Avoids out-of-bounds _world_xforms access for environment IDs greater than zero.
  • Preserves existing indexing for replicated, multi-world builders.
  • Adds a multi-environment regression test covering the original failure path.
  • Documents the fix in a changelog fragment.

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 NewtonSiteFrameView is 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_ids use the same _world_xforms[0] when only one Newton world exists. Because the same site-local xform is 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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

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

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant