2222
2323from collections .abc import Iterator
2424from dataclasses import dataclass
25- from unittest .mock import patch
2625
2726import numpy as np
2827import pytest
3938from isaaclab_ov .assets import RigidObject , RigidObjectCollection # noqa: E402
4039from isaaclab_ov .physics import OvPhysxCfg # noqa: E402
4140from isaaclab_ov .sim .views import OvPhysxView # noqa: E402
42- from isaaclab_ov .test .fixtures .views .session_reads import binding_values , replays_only # noqa: E402
41+ from isaaclab_ov .test .fixtures .views .session_reads import binding_values , captures_again , replays_only # noqa: E402
4342from ovphysx .types import SimObjectType # noqa: E402
4443
4544import isaaclab .sim as sim_utils # noqa: E402
@@ -302,8 +301,8 @@ def test_session_reads_after_a_native_structural_edit(device: str) -> None:
302301 """After ``invalidate_session_reads`` and a body disabled through the native handle, the next read captures again
303302 and reads the binding's values.
304303
305- It guards the invalidation itself (released plans are captured again, never replayed); with today's ovphysx a plan
306- captured before this edit also still reads correctly, so it cannot show that the edit needs the invalidation .
304+ With today's ovphysx a plan captured before this edit would still read correctly, so the recapture is asserted
305+ directly: an invalidation that kept the plans fails it .
307306 """
308307 with build_simulation_context (device = device , sim_cfg = SimulationCfg (physics = OvPhysxCfg (), device = device )) as sim :
309308 cubes = _spawn_cubes ("Edited" , y_offset = 0.0 )
@@ -323,7 +322,8 @@ def test_session_reads_after_a_native_structural_edit(device: str) -> None:
323322 for _ in range (5 ): # the second cube falls
324323 sim .step ()
325324 replayed .fill_ (- 1.0 )
326- view .read_into (TT .RIGID_BODY_POSE , replayed )
325+ with captures_again (TT .RIGID_BODY_POSE ):
326+ view .read_into (TT .RIGID_BODY_POSE , replayed )
327327 expected = binding_values (view , TT .RIGID_BODY_POSE )
328328 torch .testing .assert_close (wp .to_torch (replayed ), wp .to_torch (expected ), atol = 0.0 , rtol = 0.0 )
329329 finally :
@@ -475,9 +475,10 @@ def test_session_reads_match_bindings(scene: _RigidScene, tensor_type: int) -> N
475475 """A session read fills ``read_into`` with the binding's values in the binding's row order."""
476476 for _ in range (3 ):
477477 scene .sim .step ()
478- # A collection reads LINK_* through its RIGID_BODY_* binding; the cuboid pairs read the rigid-body types.
478+ # A collection reads LINK_* through its RIGID_BODY_* binding (one collection: they share the layout); the cuboid
479+ # pairs read the rigid-body types.
479480 served = {TT .LINK_POSE : TT .RIGID_BODY_POSE , TT .LINK_VELOCITY : TT .RIGID_BODY_VELOCITY }.get (tensor_type )
480- owners = (scene .fused , scene . stepped ) if served else (scene .dynamic , scene .kinematic , scene .spinning )
481+ owners = (scene .fused ,) if served else (scene .dynamic , scene .kinematic , scene .spinning )
481482 for owner in owners :
482483 view = owner .root_view
483484 expected = binding_values (view , tensor_type )
@@ -499,13 +500,14 @@ def test_session_read_replays_on_the_callers_stream(scene: _RigidScene, null_str
499500 replayed = wp .zeros_like (expected )
500501 view .read_into (TT .RIGID_BODY_POSE , replayed ) # captures the plan
501502 replayed .fill_ (- 1.0 )
503+ copied = wp .zeros_like (expected )
502504 wp .synchronize_device (device )
503505 stream = wp .get_device (device ).null_stream if null_stream else wp .Stream (device )
504- with wp .ScopedStream (stream ), patch . object ( wp , "capture_launch" , wraps = wp . capture_launch ) as launch :
506+ with wp .ScopedStream (stream ):
505507 view .read_into (TT .RIGID_BODY_POSE , replayed )
506- assert launch . call_args . kwargs [ "stream" ] is stream
507- wp .synchronize_device ( device )
508- torch .testing .assert_close (wp .to_torch (replayed ), wp .to_torch (expected ), atol = 0.0 , rtol = 0.0 )
508+ wp . copy ( copied , replayed ) # queued after the replay on the same stream
509+ wp .synchronize_stream ( stream ) # only this stream: a replay elsewhere leaves the copy holding -1
510+ torch .testing .assert_close (wp .to_torch (copied ), wp .to_torch (expected ), atol = 0.0 , rtol = 0.0 )
509511
510512
511513@pytest .mark .parametrize ("scene" , _CUDA_SCENES , indirect = True )
0 commit comments