Repository navigation
Description
Describe the bug
ContactSensor data read after scene.reset(env_ids) and before the next physics step still holds the previous
episode's contacts. ManagerBasedRLEnv.step computes the observations right after _reset_idx, with no physics step
in between, so this happens on every reset.
#4970 reported this, and #5782 fixed it for the PhysX net forces and for Newton by skipping environments whose sensor
timestamp is still 0. Two paths were missed:
- OVPhysX:
update_net_forces_ovphysx_kernelreceivestimestampbut never checks it, and
unpack_contact_buffer_datahas none. The reset environment's net, normal and friction forces, force matrices, all
force histories and contact points are refilled from the pre-reset contact buffers. - Isaac Sim PhysX:
unpack_contact_buffer_datais not guarded, so the contact points and, on Isaac Sim 6.1, the
filtered friction forces (and through them the friction history) are stale. Net forces are correctly zero.
A stale sample also enters the force history and stays there for history_length - 1 more sensor updates. Terms that
take the maximum over the history then see a contact that did not happen: on OVPhysX, mdp.illegal_contact fired for
a freshly reset environment whose body was in the air, on the first two env steps after the reset. Newton is not
affected.
Steps to reproduce
A cube slides on the ground under tilted gravity, with contact points and friction tracked against the ground. Env 0 is
reset as _reset_idx does (cube moved up, scene.reset(env_ids)) and the sensor is read before the next physics step.
Save as repro.py and run uv run python repro.py --physics isaacsim_physx or --physics ovphysx.
import argparse
from isaaclab.app import add_launcher_args, launch_simulation
parser = argparse.ArgumentParser()
parser.add_argument("--physics", default="isaacsim_physx", choices=["isaacsim_physx", "ovphysx"])
add_launcher_args(parser)
args_cli = parser.parse_args()
import torch
import isaaclab.sim as sim_utils
from isaaclab.assets import RigidObjectCfg
from isaaclab.physics import PhysicsCfg
from isaaclab.scene import InteractiveSceneCfg
from isaaclab.sensors import ContactSensorCfg
from isaaclab.terrains import TerrainImporterCfg
from isaaclab.utils import configclass
DT = 0.005
GROUND = "/World/ground"
@configclass
class SceneCfg(InteractiveSceneCfg):
terrain = TerrainImporterCfg(prim_path=GROUND, terrain_type="plane")
cube = RigidObjectCfg(
prim_path="{ENV_REGEX_NS}/Cube",
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)),
)
contact = ContactSensorCfg(
prim_path="{ENV_REGEX_NS}/Cube",
history_length=3,
track_contact_points=True,
track_friction_forces=True,
filter_prim_paths_expr=[GROUND + "/terrain/GroundPlane/CollisionPlane"],
)
with launch_simulation(PhysicsCfg(), args_cli) as physics_cfg:
from isaaclab.scene import InteractiveScene
from isaaclab.sim import SimulationContext
sim_cfg = sim_utils.SimulationCfg(dt=DT, device=args_cli.device, gravity=(-10.0, 0.0, -9.81), physics=physics_cfg)
sim = SimulationContext(sim_cfg)
scene = InteractiveScene(SceneCfg(num_envs=1, env_spacing=2.0))
sim.reset()
scene.reset()
cube, contact = scene["cube"], scene["contact"]
def step():
scene.write_data_to_sim()
sim.step(render=False)
scene.update(DT)
def show(tag):
data = contact.data
friction_history = torch.linalg.norm(data.friction_force_matrix_w_history.torch[0, :, 0, 0], dim=-1)
print(
f"{tag:<13} normal_z={data.net_normal_forces_w.torch[0, 0, 2].item():7.3f}"
f" friction_x={data.friction_force_matrix_w.torch[0, 0, 0, 0].item():7.3f}"
f" friction_history={[round(v, 3) for v in friction_history.tolist()]}"
f" contact_pos={[round(v, 3) for v in data.contact_pos_w.torch[0, 0, 0].tolist()]}"
)
for _ in range(40):
step()
show("before reset")
env_ids = torch.tensor([0], device=cube.device)
pose = cube.data.root_link_pose_w.torch.clone()
pose[:, 2] += 1.0
cube.write_root_pose_to_sim_index(root_pose=pose, env_ids=env_ids)
cube.write_root_velocity_to_sim_index(root_velocity=torch.zeros((1, 6), device=cube.device), env_ids=env_ids)
scene.reset(env_ids)
show("after reset")
step()
show("next step")Actual, --physics isaacsim_physx (Isaac Sim 6.1):
before reset normal_z= 9.812 friction_x= 4.906 friction_history=[4.906, 4.903, 4.905] contact_pos=[-0.107, -0.0, -0.0]
after reset normal_z= 0.000 friction_x= 4.906 friction_history=[4.906, 0.0, 0.0] contact_pos=[-0.107, -0.0, -0.0]
next step normal_z= 0.000 friction_x= 0.000 friction_history=[0.0, 4.906, 0.0] contact_pos=[nan, nan, nan]
Actual, --physics ovphysx:
before reset normal_z= 9.793 friction_x= 4.895 friction_history=[4.896, 4.909, 4.894] contact_pos=[-0.102, 0.001, -0.0]
after reset normal_z= 9.793 friction_x= 4.895 friction_history=[4.896, 0.0, 0.0] contact_pos=[-0.102, 0.001, -0.0]
next step normal_z= 0.000 friction_x= 0.000 friction_history=[0.0, 4.896, 0.0] contact_pos=[nan, nan, nan]
Expected on both backends, as for the PhysX net forces and Newton: the reset values until the sensor's next update.
after reset normal_z= 0.000 friction_x= 0.000 friction_history=[0.0, 0.0, 0.0] contact_pos=[nan, nan, nan]
next step normal_z= 0.000 friction_x= 0.000 friction_history=[0.0, 0.0, 0.0] contact_pos=[nan, nan, nan]
System Info
- Commit: d652aa9 (develop); the same code is on release/3.0.0 (d061bf3)
- Isaac Sim Version: 6.1.0-rc.26 (PhysX; for 6.2.0 see Additional context); OVPhysX 0.6.4 (kitless)
- OS: Ubuntu 24.04
- GPU: NVIDIA RTX PRO 5000 Blackwell
- CUDA: 13.0
- GPU Driver: 580.126.20
Additional context
On Isaac Sim 6.2 the filtered friction goes through the already guarded aggregate path, while the contact points still
go through unpack_contact_buffer_data. On Isaac Sim 6.2.0 (develop 9b6d2d8, environment synced from its uv.lock),
the PhysX repro shows exactly that: after the reset friction_x reads 0.000 and friction_history is cleared, while
contact_pos keeps the pre-reset [-0.107, -0.0, -0.0]. The OVPhysX output there is the same as above.
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
- OVPhysX and Isaac Sim PhysX
ContactSensordata read afterscene.reset(env_ids)and before the next physics
step returns the reset values (zero forces and histories, NaN contact points) for the reset environments. - No pre-reset sample enters the force histories.
Activity
RandomOakForest commentedon Oct 16, 2026
Thank you for posting this and adding the PR. The team will review it.
Fix stale OVPhysX and PhysX contact sensor data after reset (#8608)