fix(newton): split flat-builder site injection per environment - #7672
fix(newton): split flat-builder site injection per environment#7672pascal-roth wants to merge 2 commits into
Conversation
_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.
The PR is not safe to merge until the fallback retains support for single-world flat body labels without an environment namespace. Findings
|
| 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." | ||
| ) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_worldsite 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_newtonsource package, or an explicit.skipfragment 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)]) |
There was a problem hiding this comment.
🟡 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).
Description
_cl_inject_sites_fallback— the non-replicated/flat-builder path inisaaclab_newton'sNewtonManager, used whenever a scene is built withreplicate_physics=False— packed everyenvironment's matched site index into a single one-element outer list instead of one sublist per
environment. Any consumer indexing
per_world[env_index]forenv_index > 0(e.g.NewtonRaycastSensor._resolve_site_indices) hit anIndexErroras soon as a scene had more thanone environment with
replicate_physics=False.The fix groups matches by their
env_<N>path segment instead, so the site map has one sublistper 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=Falseand a robot-attached ray-caster sensor; confirmed the
IndexErrorbefore the fix and cleaninitialization after. Not covered by an automated CI test yet.
Type of change
Release backport
developScreenshots
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-cion the pull request.pre-commitchecks with./isaaclab.sh --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bumpextension.toml— CI handles that)CONTRIBUTORS.mdor my name already exists there