Skip to content

[Bug Report] Sensors on an asset that exists in only some environments reset the wrong environments or index past their buffers #8654

Closed

Description

@NeoZng

Describe the bug

CloneCfg.clone_combinations lets an asset exist in only some environments: "Assets not referenced by any entry
are active in every combination" (source/isaaclab/isaaclab/cloner/cloner_cfg.py:61-67). Sensors take their
environment count from the clone plan (sensors/sensor_base.py:269-271), and InteractiveScene.reset(env_ids)
passes the same environment ids to every sensor (scene/interactive_scene.py:437-459). A sensor on such an asset,
however, binds only the instances that exist, and nothing maps environment ids to its rows:

  • The OVPhysX ContactSensor, JointWrenchSensor and FrameTransformer shrink to the bound instances
    (isaaclab_ov/sensors/contact_sensor/contact_sensor.py:282-289, joint_wrench/joint_wrench_sensor.py:144-154,
    frame_transformer/frame_transformer.py:261-276).
    • scene.reset(env_ids) clears another environment's row.
    • An id past the bound rows triggers a CUDA device-side assert on GPU, after which the simulation cannot
      continue, or an IndexError on CPU.
    • A FrameTransformer whose bodies exist in different environments pairs bodies of different environments.
  • Ray casters on PhysX and OVPhysX and the PhysX Imu, Pva and JointWrenchSensor size their data by the bound
    instances, or read a view of that size, but launch their kernels over all environments
    (isaaclab/sensors/ray_caster/base_ray_caster.py:241-249 vs :279-334; isaaclab_physx/sensors/imu/imu.py:255
    vs :109, :235). Their rows hold other environments' data, resets clear the wrong rows, and the kernels index
    past the buffers.
  • The PhysX FrameTransformer fails at initialization with an unrelated error: ValueError: '/World/envs/Crate' is not in list (environment 0 lacks the asset) or IndexError: list index out of range (environment 0 has it).

The PhysX ContactSensor, the OVPhysX Imu/Pva and the Camera already reject this setup at initialization.
On Newton, the Lab asset views reject such scenes, and without Lab assets SolverMuJoCo does ("requires
homogeneous worlds").

Steps to reproduce

Synthetic scene: three environments, with a crate in environments 0 and 2 only.

"""Sensor on an asset that exists in only some environments (``CloneCfg.clone_combinations``).

    python repro.py --physics ovphysx --sensor contact --device cuda:0
    python repro.py --physics ovphysx --sensor contact --device cpu
    python repro.py --physics isaacsim_physx --sensor imu --device cuda:0
    python repro.py --physics ovphysx --sensor ray_caster --device cpu
    python repro.py --physics ovphysx --write --device cuda:0
"""

import argparse

from isaaclab.app import add_launcher_args, launch_simulation
from isaaclab.physics import PhysicsCfg

parser = argparse.ArgumentParser()
parser.add_argument("--physics", default="ovphysx", choices=["ovphysx", "isaacsim_physx"])
parser.add_argument("--sensor", default="contact", choices=["contact", "imu", "ray_caster"])
parser.add_argument("--write", action="store_true", help="write the crate pose of environment 1 and exit")
add_launcher_args(parser)
args_cli = parser.parse_args()


def main():
    with launch_simulation(PhysicsCfg(), args_cli) as physics_cfg:
        # import USD-dependent modules after the launch
        import torch

        import isaaclab.sim as sim_utils
        from isaaclab import cloner
        from isaaclab.assets import RigidObjectCfg
        from isaaclab.scene import InteractiveScene, InteractiveSceneCfg
        from isaaclab.sensors import ContactSensorCfg, ImuCfg, RayCasterCfg, patterns
        from isaaclab.terrains import TerrainImporterCfg
        from isaaclab.utils import configclass

        @configclass
        class SceneCfg(InteractiveSceneCfg):
            terrain = TerrainImporterCfg(prim_path="/World/ground", terrain_type="plane")
            crate = RigidObjectCfg(
                prim_path="{ENV_REGEX_NS}/Crate",
                spawn=sim_utils.CuboidCfg(
                    size=(0.2, 0.2, 0.2),
                    rigid_props=sim_utils.UsdPhysicsRigidBodyCfg(),
                    mass_props=sim_utils.MassCfg(mass=1.0),
                    collision_props=sim_utils.UsdPhysicsCollisionCfg(),
                    activate_contact_sensors=True,
                ),
                init_state=RigidObjectCfg.InitialStateCfg(pos=(0.0, 0.0, 0.1)),
            )
            sensor = None

        sensors = {
            "contact": ContactSensorCfg(prim_path="{ENV_REGEX_NS}/Crate", track_pose=True, track_air_time=True),
            "imu": ImuCfg(prim_path="{ENV_REGEX_NS}/Crate"),
            "ray_caster": RayCasterCfg(
                prim_path="{ENV_REGEX_NS}/Crate",
                mesh_prim_paths=["/World/ground"],
                pattern_cfg=patterns.GridPatternCfg(resolution=0.1, size=(0.0, 0.0)),
            ),
        }

        sim = sim_utils.SimulationContext(
            sim_utils.SimulationCfg(dt=0.005, device=args_cli.device, physics=physics_cfg)
        )
        scene_cfg = SceneCfg(num_envs=3, env_spacing=2.0)
        scene_cfg.sensor = sensors[args_cli.sensor]
        # sequential cloning: environment i gets combination i, so only environments 0 and 2 have the crate
        with_crate, without_crate = cloner.InclusionSet(assets=["crate"]), cloner.InclusionSet(assets=[])
        scene_cfg.clone_cfg.clone_combinations = [with_crate, without_crate, with_crate]
        scene = InteractiveScene(scene_cfg)
        sim.reset()

        def step(n):
            for _ in range(n):
                sim.step()
                scene.update(sim.get_physics_dt())

        def show(tag):
            data = scene["sensor"].data
            if args_cli.sensor == "contact":
                rows = {"pos_w": data.pos_w.torch[:, 0], "current_contact_time": data.current_contact_time.torch}
            elif args_cli.sensor == "imu":
                rows = {"lin_acc_b": data.lin_acc_b.torch}
            else:
                rows = {"pos_w": data.pos_w.torch}
            text = ", ".join(f"{k}={[[round(v, 2) for v in r] for r in t.tolist()]}" for k, t in rows.items())
            print(f"[{tag}] {text}", flush=True)

        print(f"num_envs={scene.num_envs} env_origins={scene.env_origins[:, :2].tolist()}", flush=True)
        crate = scene["crate"]
        print(f"crate num_instances={crate.num_instances} rows={crate.data.root_pos_w.torch.tolist()}", flush=True)
        if args_cli.write:
            # environment 1 has no crate: lift a crate 1 m above its origin
            pose = torch.tensor([[*scene.env_origins[1, :2].tolist(), 1.0, 0.0, 0.0, 0.0, 1.0]], device=sim.device)
            crate.write_root_pose_to_sim_index(root_pose=pose, env_ids=torch.tensor([1], device=sim.device))
            step(1)
            print(f"after crate write to env 1: rows={crate.data.root_pos_w.torch.tolist()}", flush=True)
            return
        step(60)
        show("after 60 steps")
        scene.reset(torch.tensor([1], device=sim.device))  # environment 1 has no crate
        show("after scene.reset([1])")
        step(1)
        scene.reset(torch.tensor([2], device=sim.device))
        step(1)
        show("after scene.reset([2])")


if __name__ == "__main__":
    main()

Environment origins are [[1, -1], [1, 1], [-1, -1]]; the crate has two instances, at the origins of environments 0
and 2. Coordinates are rounded below.

OVPhysX ContactSensor, GPU. Resetting environment 1, which has no crate, clears the contact time of
environment 2's crate. Resetting environment 2 trips a device-side assert in index_fill_, and the next step fails:

[after 60 steps] pos_w=[[1.0, -1.0, 0.1], [-1.0, -1.0, 0.1]], current_contact_time=[[0.3], [0.3]]
[after scene.reset([1])] pos_w=[[1.0, -1.0, 0.1], [-1.0, -1.0, 0.1]], current_contact_time=[[0.3], [0.0]]
.../ATen/native/cuda/IndexKernel.cu:154: ... Assertion `idx >= -self_dim_size && idx < self_dim_size && "index out of bounds"` failed.
RuntimeError: step_sync failed: GPU simulation cannot continue: CUDA error 710.

OVPhysX ContactSensor, CPU. The first two lines are the same, then:

  File ".../isaaclab/scene/interactive_scene.py", line 459, in reset
  File ".../isaaclab_ov/sensors/contact_sensor/contact_sensor.py", line 502, in reset
  File ".../isaaclab/sensors/sensor_base.py", line 486, in _resolve_indices_and_mask
IndexError: index 2 is out of bounds for dimension 0 with size 2

PhysX Imu, GPU. The IMU has two rows for three environments. Resetting environment 1 zeroes environment 2's
reading:

[after 60 steps] lin_acc_b=[[0.0, -0.0, 9.81], [-0.0, -0.0, 9.81]]
[after scene.reset([1])] lin_acc_b=[[0.0, -0.0, 9.81], [0.0, 0.0, 0.0]]

OVPhysX RayCaster, CPU. The process aborts with heap corruption after the resets:

[after scene.reset([2])] pos_w=[[1.0, -1.0, 0.1], [-1.0, -1.0, 0.1]]
free(): invalid next size (fast)
Aborted (core dumped)

System Info

  • Commit: 06f2d42fdf (develop); the OVPhysX contact-sensor output is the same on develop 9b6d2d8 in an
    environment synced from its uv.lock
  • Isaac Sim Version: 6.1.0-rc.26 for the PhysX run; OVPhysX 0.6.4 (kitless) for the OVPhysX runs
  • OS: Ubuntu 24.04.2 LTS
  • GPU: NVIDIA RTX PRO 5000 72GB Blackwell
  • CUDA: 13.0
  • GPU Driver: 580.126.20

Additional context

Supporting these sensors needs an environment-index contract for such assets, which the assets do not have
either. They index their own rows: crate.num_instances == 2, and --write (OVPhysX, GPU) shows that a pose write
to environment 1, which has no crate, moves environment 2's crate there:

crate num_instances=2 rows=[[1.0, -1.0, 0.1], [-1.0, -1.0, 0.1]]
after crate write to env 1: rows=[[1.0, -1.0, 0.1], [1.0, 1.0, 1.0]]

So InteractiveScene.reset(env_ids) and the asset index writes address the wrong environments for these assets
too. examples/bin_packing.py maps rows to environments from prim paths and resets all environments. A sensor that
mapped environment ids on its own would disagree with its asset within one scene.reset(env_ids) call. The options
are:

  • environment ids everywhere, with a per-binding environment map. Either the rows are the covered environments
    and a row-to-environment map is exposed, or there are num_envs rows with padding;
  • local rows everywhere, with InteractiveScene translating environment ids for each entity, which the contrib
    multitask manipulation environment already does for its own assets (SceneEntitySelectionCfg).

Until one is chosen, these sensors should fail at initialization with a clear error, as the PhysX ContactSensor
does.

Contact sensors on PhysX and OVPhysX already fail at initialization when environment 0 lacks the asset, but with a
misleading hint about activate_contact_sensors; this is unchanged here.

Related:

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have checked that the issue is not in running Isaac Sim itself and is related to the repo

Acceptance Criteria

  • Ray casters and ray-caster cameras, the PhysX Imu, Pva, JointWrenchSensor and FrameTransformer, and the OVPhysX ContactSensor, JointWrenchSensor and FrameTransformer fail at initialization with an error that names the sensor when the asset they are attached to exists in only some environments.

An environment-index contract that would let sensors support such assets is future work.

Activity

  1. RandomOakForest commented on Oct 16, 2026

    @RandomOakForest
    Collaborator

    Thank you for posting this and adding the PR. The team will review it.

  2. added
    bug
    on Oct 16, 2026
  3. added a commit that references this issue on Oct 23, 2026
    1d1a808
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions