Skip to content

fix(newton): split flat-builder site injection per environment - #7672

Open
pascal-roth wants to merge 2 commits into
isaac-sim:developfrom
pascal-roth:fix/newton-flat-builder-per-env-sites
Open

fix(newton): split flat-builder site injection per environment#7672
pascal-roth wants to merge 2 commits into
isaac-sim:developfrom
pascal-roth:fix/newton-flat-builder-per-env-sites

Conversation

@pascal-roth

@pascal-roth pascal-roth commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Description

_cl_inject_sites_fallback — the non-replicated/flat-builder path in isaaclab_newton's
NewtonManager, used whenever a scene is built with replicate_physics=False — packed every
environment's matched site index into a single one-element outer list instead of one sublist per
environment. Any consumer indexing per_world[env_index] for env_index > 0 (e.g.
NewtonRaycastSensor._resolve_site_indices) hit an IndexError as soon as a scene had more than
one environment with replicate_physics=False.

The fix groups matches by their env_<N> path segment instead, so the site map has one sublist
per environment, matching the convention already used by the replicated builder path.

Fixes # (issue)

Test plan: Reproduced against a custom multi-environment task with replicate_physics=False
and a robot-attached ray-caster sensor; confirmed the IndexError before the fix and clean
initialization after. Not covered by an automated CI test yet.

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

Screenshots

N/A — backend indexing fix, no visual output.

Checklist

Docker and GPU tests run on demand. Push the commits you want tested, then
comment run-ci on the pull request.

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --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 or that my feature works
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package (do not edit CHANGELOG.rst or bump extension.toml — CI handles that)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

_cl_inject_sites_fallback (the non-replicated/flat-builder path, used when
replicate_physics=False) packed every environment's matched site index into a
single one-element outer list instead of one sublist per environment. Any
consumer indexing per_world[env_index] for env_index > 0 (e.g.
NewtonRaycastSensor._resolve_site_indices) hit an IndexError as soon as a
scene had more than one environment.

Group matches by their env_<N> path segment instead, so the site map has one
sublist per environment, matching the replicated-builder convention.
@pascal-roth
pascal-roth requested a review from a team September 9, 2026 07:05
@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: 4/5

The PR is not safe to merge until the fallback retains support for single-world flat body labels without an environment namespace.

Findings

  1. P1 Flat labels now fail

Summary

  • Aligns multi-environment fallback maps with consumers that index sites by environment.
  • Introduces a regression for supported flat, single-world body labels that lack an environment namespace.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Match flat-builder body labels] --> B{Label contains env_N?}
  B -->|Yes| C[Group site under environment N]
  C --> D[Build one sublist per environment]
  B -->|No| E[Current change raises ValueError]
  E --> F[Single-world flat-label initialization fails]
Loading

Comment on lines +1452 to +1458
env_match = re.search(r"/env_(\d+)(?:/|$)", body_name)
if env_match is None:
raise ValueError(
f"Site '{label}' with body_pattern '{body_pattern}' matched body '{body_name}', "
"which has no 'env_<N>' path segment. The flat (non-replicated) builder needs "
"each match tied to an environment index to build a per-environment site map."
)

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.

P1 Flat labels now fail

The fallback API supports flat body labels such as Robot/base, and the existing single-body and wildcard tests use labels without an env_<N> segment. This new check raises for those supported single-world scenes, so body-attached sensors fail during site injection instead of receiving a one-world site map. Please preserve the existing one-world behavior when matched labels have no environment namespace.

@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 flat-builder site map is correctly split into per-environment sublists, restoring the structure expected by environment-indexing consumers. The user-visible bug fix is missing the required changelog fragment for isaaclab_newton.

  • Design and architecture: Normalizing the non-replicated builder output to the same per-environment structure used by the replicated path is appropriate, while global and per_world site handling remains unchanged.
  • API: The corrected local-site map shape matches the existing consumer contract. No supported public API compatibility issue is established by the patch.
  • Implementation: The grouping logic directly addresses the multi-environment indexing failure. Before merge, add the repository-required bug-fix changelog fragment for the changed isaaclab_newton source package, or an explicit .skip fragment if appropriate.

Minor fixes needed. Posted 1 actionable finding inline.

Automated review; human maintainers own approval decisions.

# Single world (no replication): one-element outer list
cls._cl_site_index_map[label] = (None, [site_indices])
num_envs = max(sites_by_env) + 1
cls._cl_site_index_map[label] = (None, [sites_by_env.get(i, []) for i in range(num_envs)])

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 — Missing changelog fragment for isaaclab_newton

Repository rules require one changelog fragment per changed source package for user-visible changes, and this fixes a user-facing IndexError during scene initialization with replicate_physics=False and more than one environment. Only the source file is present in this PR. Add a bug-fix fragment for isaaclab_newton describing the corrected per-environment flat-builder site mapping (or a .skip fragment if intentionally unreleased).

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

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants