From 1f751c04f194a224eb1368b481c8f32c52d13858 Mon Sep 17 00:00:00 2001 From: Kelly Guo Date: Fri, 7 Nov 2025 15:18:20 -0800 Subject: [PATCH 1/7] Adds disable sleeping and apply forces in lockstep with solver steps --- source/isaaclab/config/extension.toml | 2 +- source/isaaclab/docs/CHANGELOG.rst | 17 +++ .../isaaclab/isaaclab/sim/simulation_cfg.py | 20 ++++ .../isaaclab/sim/simulation_context.py | 20 ++++ .../test/sim/test_simulation_context.py | 106 ++++++++++++++++++ 5 files changed, 164 insertions(+), 1 deletion(-) diff --git a/source/isaaclab/config/extension.toml b/source/isaaclab/config/extension.toml index 748d15c9779..2c6bb3a4580 100644 --- a/source/isaaclab/config/extension.toml +++ b/source/isaaclab/config/extension.toml @@ -1,7 +1,7 @@ [package] # Note: Semantic Versioning is used: https://semver.org/ -version = "0.47.11" +version = "0.49.0" # Description title = "Isaac Lab framework for Robot Learning" diff --git a/source/isaaclab/docs/CHANGELOG.rst b/source/isaaclab/docs/CHANGELOG.rst index 1a9efab4a03..03580f97b8a 100644 --- a/source/isaaclab/docs/CHANGELOG.rst +++ b/source/isaaclab/docs/CHANGELOG.rst @@ -1,6 +1,23 @@ Changelog --------- +0.49.0 (2025-11-07) +~~~~~~~~~~~~~~~~~~~ + +Added +^^^^^ + +* Added two new PhysX configuration parameters to :class:`~isaaclab.sim.PhysxCfg`: + + - :attr:`~isaaclab.sim.PhysxCfg.disable_sleeping`: Disables sleeping for all objects in the physics scene on a global level. + This flag is set to ``True`` by default and overrides any sleeping settings on individual bodies. If sleeping is required + on any individual body, this flag must be set to ``False``. Note that if ``disable_sleeping`` is set to ``False`` and the + directGPU pipeline is enabled, PhysX will issue an error and fail scene creation. + - :attr:`~isaaclab.sim.PhysxCfg.enable_external_forces_every_iteration`: Enables external forces to be applied every iteration. + This flag is set to ``False`` by default (standard PhysX behavior). Setting this to ``True`` can reduce noisy joint velocity + data from PhysX at a slight performance cost. + + 0.47.11 (2025-11-03) ~~~~~~~~~~~~~~~~~~~~ diff --git a/source/isaaclab/isaaclab/sim/simulation_cfg.py b/source/isaaclab/isaaclab/sim/simulation_cfg.py index 380dba26c51..8bd386d3561 100644 --- a/source/isaaclab/isaaclab/sim/simulation_cfg.py +++ b/source/isaaclab/isaaclab/sim/simulation_cfg.py @@ -180,6 +180,26 @@ class PhysxCfg: """ + disable_sleeping: bool = True + """Disable sleeping for all objects in the physics scene on a global level. Default is True. + + This flag disables sleeping for all objects in the scene, overriding any sleeping settings on individual bodies. + If sleeping is required on any individual body, this flag must be set to False. + + .. warning:: + + If :attr:`disable_sleeping` is set to False and the GPU pipeline is enabled, PhysX will issue an error + message and fail scene creation as this is not supported. + """ + + enable_external_forces_every_iteration: bool = False + """Enable external forces to be applied every iteration. Default is False. + + When set to False (default), external forces are applied using the standard PhysX behavior, which may lead + to noisy joint velocity data from PhysX. Setting this to True will apply external forces at every iteration, + which can reduce the noise in joint velocity data at a slight performance cost. + """ + @configclass class RenderCfg: diff --git a/source/isaaclab/isaaclab/sim/simulation_context.py b/source/isaaclab/isaaclab/sim/simulation_context.py index 83277635acf..c3d71a82b7c 100644 --- a/source/isaaclab/isaaclab/sim/simulation_context.py +++ b/source/isaaclab/isaaclab/sim/simulation_context.py @@ -792,6 +792,26 @@ def _set_additional_physx_params(self): physx_prim.CreateAttribute("physxScene:solveArticulationContactLast", Sdf.ValueTypeNames.Bool).Set( self.cfg.physx.solve_articulation_contact_last ) + # -- Disable sleeping globally + # This overrides any sleeping settings on individual bodies + physx_prim.CreateAttribute("physxSceneAPI:disableSleeping", Sdf.ValueTypeNames.Bool).Set( + self.cfg.physx.disable_sleeping + ) + # Check if disable_sleeping is False with GPU pipeline enabled + if not self.cfg.physx.disable_sleeping: + # Check if GPU pipeline is enabled via the suppressReadback flag + suppress_readback = self.carb_settings.get_as_bool("/physics/suppressReadback") + if suppress_readback: + raise RuntimeError( + "PhysX configuration error: 'disable_sleeping' is set to False while GPU pipeline is enabled " + "(/physics/suppressReadback=True). This combination will cause PhysX to fail scene creation. " + "Please set 'cfg.physx.disable_sleeping = True' or disable GPU pipeline." + ) + # -- Enable external forces every iteration + # This can help reduce noisy joint velocity data from PhysX at a slight performance cost + physx_scene_api.CreateEnableExternalForcesEveryIterationAttr( + self.cfg.physx.enable_external_forces_every_iteration + ) # -- Gravity # note: Isaac sim only takes the "up-axis" as the gravity direction. But physics allows any direction so we diff --git a/source/isaaclab/test/sim/test_simulation_context.py b/source/isaaclab/test/sim/test_simulation_context.py index f0f783463d2..b98ff8c3588 100644 --- a/source/isaaclab/test/sim/test_simulation_context.py +++ b/source/isaaclab/test/sim/test_simulation_context.py @@ -146,3 +146,109 @@ def test_zero_gravity(): gravity_dir, gravity_mag = sim.get_physics_context().get_gravity() gravity = np.array(gravity_dir) * gravity_mag np.testing.assert_almost_equal(gravity, cfg.gravity) + + +@pytest.mark.isaacsim_ci +def test_disable_sleeping_setting(): + """Test that the disable_sleeping PhysX setting is applied correctly.""" + from pxr import PhysxSchema + + # Test with disable_sleeping set to True (default) + cfg = SimulationCfg() + assert cfg.physx.disable_sleeping is True + + sim = SimulationContext(cfg) + + # Get the physics scene prim and check the attribute + stage = sim.stage + physics_scene_prim = stage.GetPrimAtPath(cfg.physics_prim_path) + assert physics_scene_prim.IsValid() + + # Check that the attribute exists and is set to True + disable_sleeping_attr = physics_scene_prim.GetAttribute("physxSceneAPI:disableSleeping") + assert disable_sleeping_attr.IsValid() + assert disable_sleeping_attr.Get() is True + + +@pytest.mark.isaacsim_ci +def test_disable_sleeping_false_with_cpu(): + """Test that disable_sleeping can be set to False when using CPU simulation.""" + from pxr import PhysxSchema + + # Test with disable_sleeping set to False and CPU device + cfg = SimulationCfg(device="cpu") + cfg.physx.disable_sleeping = False + + sim = SimulationContext(cfg) + + # Get the physics scene prim and check the attribute + stage = sim.stage + physics_scene_prim = stage.GetPrimAtPath(cfg.physics_prim_path) + assert physics_scene_prim.IsValid() + + # Check that the attribute exists and is set to False + disable_sleeping_attr = physics_scene_prim.GetAttribute("physxSceneAPI:disableSleeping") + assert disable_sleeping_attr.IsValid() + assert disable_sleeping_attr.Get() is False + + +@pytest.mark.isaacsim_ci +def test_disable_sleeping_false_with_gpu_raises_error(): + """Test that disable_sleeping=False with GPU simulation raises an error.""" + # Test with disable_sleeping set to False and GPU device + cfg = SimulationCfg(device="cuda:0") + cfg.physx.disable_sleeping = False + + # This should raise a RuntimeError because GPU pipeline + disable_sleeping=False is not supported + with pytest.raises(RuntimeError, match="disable_sleeping.*GPU pipeline"): + SimulationContext(cfg) + + +@pytest.mark.isaacsim_ci +def test_enable_external_forces_every_iteration_setting(): + """Test that the enable_external_forces_every_iteration PhysX setting is applied correctly.""" + from pxr import PhysxSchema + + # Test with enable_external_forces_every_iteration set to False (default) + cfg = SimulationCfg() + assert cfg.physx.enable_external_forces_every_iteration is False + + sim = SimulationContext(cfg) + + # Get the physics scene API and check the attribute + stage = sim.stage + physics_scene_prim = stage.GetPrimAtPath(cfg.physics_prim_path) + assert physics_scene_prim.IsValid() + + physx_scene_api = PhysxSchema.PhysxSceneAPI(physics_scene_prim) + assert physx_scene_api + + # Check that the attribute exists and is set to False + enable_external_forces_attr = physx_scene_api.GetEnableExternalForcesEveryIterationAttr() + assert enable_external_forces_attr.IsValid() + assert enable_external_forces_attr.Get() is False + + +@pytest.mark.isaacsim_ci +def test_enable_external_forces_every_iteration_true(): + """Test that enable_external_forces_every_iteration can be set to True.""" + from pxr import PhysxSchema + + # Test with enable_external_forces_every_iteration set to True + cfg = SimulationCfg() + cfg.physx.enable_external_forces_every_iteration = True + + sim = SimulationContext(cfg) + + # Get the physics scene API and check the attribute + stage = sim.stage + physics_scene_prim = stage.GetPrimAtPath(cfg.physics_prim_path) + assert physics_scene_prim.IsValid() + + physx_scene_api = PhysxSchema.PhysxSceneAPI(physics_scene_prim) + assert physx_scene_api + + # Check that the attribute exists and is set to True + enable_external_forces_attr = physx_scene_api.GetEnableExternalForcesEveryIterationAttr() + assert enable_external_forces_attr.IsValid() + assert enable_external_forces_attr.Get() is True From 6eb61055fecef87d29e85b5ed185d5b0294f9e49 Mon Sep 17 00:00:00 2001 From: Kelly Guo Date: Fri, 7 Nov 2025 15:27:20 -0800 Subject: [PATCH 2/7] Update source/isaaclab/test/sim/test_simulation_context.py Signed-off-by: Kelly Guo --- source/isaaclab/test/sim/test_simulation_context.py | 1 - 1 file changed, 1 deletion(-) diff --git a/source/isaaclab/test/sim/test_simulation_context.py b/source/isaaclab/test/sim/test_simulation_context.py index b98ff8c3588..70f21c8e3ac 100644 --- a/source/isaaclab/test/sim/test_simulation_context.py +++ b/source/isaaclab/test/sim/test_simulation_context.py @@ -173,7 +173,6 @@ def test_disable_sleeping_setting(): @pytest.mark.isaacsim_ci def test_disable_sleeping_false_with_cpu(): """Test that disable_sleeping can be set to False when using CPU simulation.""" - from pxr import PhysxSchema # Test with disable_sleeping set to False and CPU device cfg = SimulationCfg(device="cpu") From 39dae3689845635a2f67d64a972fb129004634c5 Mon Sep 17 00:00:00 2001 From: Kelly Guo Date: Fri, 7 Nov 2025 15:27:26 -0800 Subject: [PATCH 3/7] Update source/isaaclab/test/sim/test_simulation_context.py Signed-off-by: Kelly Guo --- source/isaaclab/test/sim/test_simulation_context.py | 1 - 1 file changed, 1 deletion(-) diff --git a/source/isaaclab/test/sim/test_simulation_context.py b/source/isaaclab/test/sim/test_simulation_context.py index 70f21c8e3ac..ea8f68c3adb 100644 --- a/source/isaaclab/test/sim/test_simulation_context.py +++ b/source/isaaclab/test/sim/test_simulation_context.py @@ -151,7 +151,6 @@ def test_zero_gravity(): @pytest.mark.isaacsim_ci def test_disable_sleeping_setting(): """Test that the disable_sleeping PhysX setting is applied correctly.""" - from pxr import PhysxSchema # Test with disable_sleeping set to True (default) cfg = SimulationCfg() From 12c8c2c21638886c5cf7819e83ae014b8d44c861 Mon Sep 17 00:00:00 2001 From: Kelly Guo Date: Fri, 7 Nov 2025 15:27:57 -0800 Subject: [PATCH 4/7] Update source/isaaclab/isaaclab/sim/simulation_context.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Kelly Guo --- source/isaaclab/isaaclab/sim/simulation_context.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/isaaclab/isaaclab/sim/simulation_context.py b/source/isaaclab/isaaclab/sim/simulation_context.py index c3d71a82b7c..fd9c280f963 100644 --- a/source/isaaclab/isaaclab/sim/simulation_context.py +++ b/source/isaaclab/isaaclab/sim/simulation_context.py @@ -792,11 +792,6 @@ def _set_additional_physx_params(self): physx_prim.CreateAttribute("physxScene:solveArticulationContactLast", Sdf.ValueTypeNames.Bool).Set( self.cfg.physx.solve_articulation_contact_last ) - # -- Disable sleeping globally - # This overrides any sleeping settings on individual bodies - physx_prim.CreateAttribute("physxSceneAPI:disableSleeping", Sdf.ValueTypeNames.Bool).Set( - self.cfg.physx.disable_sleeping - ) # Check if disable_sleeping is False with GPU pipeline enabled if not self.cfg.physx.disable_sleeping: # Check if GPU pipeline is enabled via the suppressReadback flag @@ -807,6 +802,11 @@ def _set_additional_physx_params(self): "(/physics/suppressReadback=True). This combination will cause PhysX to fail scene creation. " "Please set 'cfg.physx.disable_sleeping = True' or disable GPU pipeline." ) + # -- Disable sleeping globally + # This overrides any sleeping settings on individual bodies + physx_prim.CreateAttribute("physxSceneAPI:disableSleeping", Sdf.ValueTypeNames.Bool).Set( + self.cfg.physx.disable_sleeping + ) # -- Enable external forces every iteration # This can help reduce noisy joint velocity data from PhysX at a slight performance cost physx_scene_api.CreateEnableExternalForcesEveryIterationAttr( From ad8eb3d1a4c88a1ee2ac08b58a21a3d798944956 Mon Sep 17 00:00:00 2001 From: Kelly Guo Date: Mon, 10 Nov 2025 15:22:12 -0800 Subject: [PATCH 5/7] keep only sleeping change --- source/isaaclab/docs/CHANGELOG.rst | 5 +- .../isaaclab/isaaclab/sim/simulation_cfg.py | 8 --- .../isaaclab/sim/simulation_context.py | 5 -- .../test/sim/test_simulation_context.py | 50 ------------------- 4 files changed, 1 insertion(+), 67 deletions(-) diff --git a/source/isaaclab/docs/CHANGELOG.rst b/source/isaaclab/docs/CHANGELOG.rst index 03580f97b8a..9ee70292c4b 100644 --- a/source/isaaclab/docs/CHANGELOG.rst +++ b/source/isaaclab/docs/CHANGELOG.rst @@ -7,15 +7,12 @@ Changelog Added ^^^^^ -* Added two new PhysX configuration parameters to :class:`~isaaclab.sim.PhysxCfg`: +* Added new PhysX configuration parameter to :class:`~isaaclab.sim.PhysxCfg`: - :attr:`~isaaclab.sim.PhysxCfg.disable_sleeping`: Disables sleeping for all objects in the physics scene on a global level. This flag is set to ``True`` by default and overrides any sleeping settings on individual bodies. If sleeping is required on any individual body, this flag must be set to ``False``. Note that if ``disable_sleeping`` is set to ``False`` and the directGPU pipeline is enabled, PhysX will issue an error and fail scene creation. - - :attr:`~isaaclab.sim.PhysxCfg.enable_external_forces_every_iteration`: Enables external forces to be applied every iteration. - This flag is set to ``False`` by default (standard PhysX behavior). Setting this to ``True`` can reduce noisy joint velocity - data from PhysX at a slight performance cost. 0.47.11 (2025-11-03) diff --git a/source/isaaclab/isaaclab/sim/simulation_cfg.py b/source/isaaclab/isaaclab/sim/simulation_cfg.py index 8bd386d3561..322c0fe84af 100644 --- a/source/isaaclab/isaaclab/sim/simulation_cfg.py +++ b/source/isaaclab/isaaclab/sim/simulation_cfg.py @@ -192,14 +192,6 @@ class PhysxCfg: message and fail scene creation as this is not supported. """ - enable_external_forces_every_iteration: bool = False - """Enable external forces to be applied every iteration. Default is False. - - When set to False (default), external forces are applied using the standard PhysX behavior, which may lead - to noisy joint velocity data from PhysX. Setting this to True will apply external forces at every iteration, - which can reduce the noise in joint velocity data at a slight performance cost. - """ - @configclass class RenderCfg: diff --git a/source/isaaclab/isaaclab/sim/simulation_context.py b/source/isaaclab/isaaclab/sim/simulation_context.py index c3d71a82b7c..8bfc61d4634 100644 --- a/source/isaaclab/isaaclab/sim/simulation_context.py +++ b/source/isaaclab/isaaclab/sim/simulation_context.py @@ -807,11 +807,6 @@ def _set_additional_physx_params(self): "(/physics/suppressReadback=True). This combination will cause PhysX to fail scene creation. " "Please set 'cfg.physx.disable_sleeping = True' or disable GPU pipeline." ) - # -- Enable external forces every iteration - # This can help reduce noisy joint velocity data from PhysX at a slight performance cost - physx_scene_api.CreateEnableExternalForcesEveryIterationAttr( - self.cfg.physx.enable_external_forces_every_iteration - ) # -- Gravity # note: Isaac sim only takes the "up-axis" as the gravity direction. But physics allows any direction so we diff --git a/source/isaaclab/test/sim/test_simulation_context.py b/source/isaaclab/test/sim/test_simulation_context.py index b98ff8c3588..0f17df7aeb0 100644 --- a/source/isaaclab/test/sim/test_simulation_context.py +++ b/source/isaaclab/test/sim/test_simulation_context.py @@ -202,53 +202,3 @@ def test_disable_sleeping_false_with_gpu_raises_error(): # This should raise a RuntimeError because GPU pipeline + disable_sleeping=False is not supported with pytest.raises(RuntimeError, match="disable_sleeping.*GPU pipeline"): SimulationContext(cfg) - - -@pytest.mark.isaacsim_ci -def test_enable_external_forces_every_iteration_setting(): - """Test that the enable_external_forces_every_iteration PhysX setting is applied correctly.""" - from pxr import PhysxSchema - - # Test with enable_external_forces_every_iteration set to False (default) - cfg = SimulationCfg() - assert cfg.physx.enable_external_forces_every_iteration is False - - sim = SimulationContext(cfg) - - # Get the physics scene API and check the attribute - stage = sim.stage - physics_scene_prim = stage.GetPrimAtPath(cfg.physics_prim_path) - assert physics_scene_prim.IsValid() - - physx_scene_api = PhysxSchema.PhysxSceneAPI(physics_scene_prim) - assert physx_scene_api - - # Check that the attribute exists and is set to False - enable_external_forces_attr = physx_scene_api.GetEnableExternalForcesEveryIterationAttr() - assert enable_external_forces_attr.IsValid() - assert enable_external_forces_attr.Get() is False - - -@pytest.mark.isaacsim_ci -def test_enable_external_forces_every_iteration_true(): - """Test that enable_external_forces_every_iteration can be set to True.""" - from pxr import PhysxSchema - - # Test with enable_external_forces_every_iteration set to True - cfg = SimulationCfg() - cfg.physx.enable_external_forces_every_iteration = True - - sim = SimulationContext(cfg) - - # Get the physics scene API and check the attribute - stage = sim.stage - physics_scene_prim = stage.GetPrimAtPath(cfg.physics_prim_path) - assert physics_scene_prim.IsValid() - - physx_scene_api = PhysxSchema.PhysxSceneAPI(physics_scene_prim) - assert physx_scene_api - - # Check that the attribute exists and is set to True - enable_external_forces_attr = physx_scene_api.GetEnableExternalForcesEveryIterationAttr() - assert enable_external_forces_attr.IsValid() - assert enable_external_forces_attr.Get() is True From bd9fb4cd85fd507d0ca4356c5bb7c5ec06f8d211 Mon Sep 17 00:00:00 2001 From: Kelly Guo Date: Mon, 10 Nov 2025 16:00:49 -0800 Subject: [PATCH 6/7] Update source/isaaclab/isaaclab/sim/simulation_context.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Kelly Guo --- .../isaaclab/isaaclab/sim/simulation_context.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/source/isaaclab/isaaclab/sim/simulation_context.py b/source/isaaclab/isaaclab/sim/simulation_context.py index 55080cbe4c7..dc6030a43c7 100644 --- a/source/isaaclab/isaaclab/sim/simulation_context.py +++ b/source/isaaclab/isaaclab/sim/simulation_context.py @@ -792,16 +792,13 @@ def _set_additional_physx_params(self): physx_prim.CreateAttribute("physxScene:solveArticulationContactLast", Sdf.ValueTypeNames.Bool).Set( self.cfg.physx.solve_articulation_contact_last ) + ) + # -- Disable sleeping globally + # This overrides any sleeping settings on individual bodies + physx_prim.CreateAttribute("physxSceneAPI:disableSleeping", Sdf.ValueTypeNames.Bool).Set( + self.cfg.physx.disable_sleeping + ) # Check if disable_sleeping is False with GPU pipeline enabled - if not self.cfg.physx.disable_sleeping: - # Check if GPU pipeline is enabled via the suppressReadback flag - suppress_readback = self.carb_settings.get_as_bool("/physics/suppressReadback") - if suppress_readback: - raise RuntimeError( - "PhysX configuration error: 'disable_sleeping' is set to False while GPU pipeline is enabled " - "(/physics/suppressReadback=True). This combination will cause PhysX to fail scene creation. " - "Please set 'cfg.physx.disable_sleeping = True' or disable GPU pipeline." - ) # -- Gravity # note: Isaac sim only takes the "up-axis" as the gravity direction. But physics allows any direction so we From ca0fd207d2ec22884bdb123cdab9054c72f60d2e Mon Sep 17 00:00:00 2001 From: Kelly Guo Date: Mon, 10 Nov 2025 16:07:42 -0800 Subject: [PATCH 7/7] Update simulation_context.py Signed-off-by: Kelly Guo --- source/isaaclab/isaaclab/sim/simulation_context.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/source/isaaclab/isaaclab/sim/simulation_context.py b/source/isaaclab/isaaclab/sim/simulation_context.py index dc6030a43c7..fb39ec63329 100644 --- a/source/isaaclab/isaaclab/sim/simulation_context.py +++ b/source/isaaclab/isaaclab/sim/simulation_context.py @@ -792,13 +792,22 @@ def _set_additional_physx_params(self): physx_prim.CreateAttribute("physxScene:solveArticulationContactLast", Sdf.ValueTypeNames.Bool).Set( self.cfg.physx.solve_articulation_contact_last ) - ) + # -- Disable sleeping globally + # Check if disable_sleeping is False with GPU pipeline enabled + if not self.cfg.physx.disable_sleeping: + # Check if GPU pipeline is enabled via the suppressReadback flag + suppress_readback = self.carb_settings.get_as_bool("/physics/suppressReadback") + if suppress_readback: + raise RuntimeError( + "PhysX configuration error: 'disable_sleeping' is set to False while GPU pipeline is enabled " + "(/physics/suppressReadback=True). This combination will cause PhysX to fail scene creation. " + "Please set 'cfg.physx.disable_sleeping = True' or disable GPU pipeline." + ) # This overrides any sleeping settings on individual bodies physx_prim.CreateAttribute("physxSceneAPI:disableSleeping", Sdf.ValueTypeNames.Bool).Set( self.cfg.physx.disable_sleeping ) - # Check if disable_sleeping is False with GPU pipeline enabled # -- Gravity # note: Isaac sim only takes the "up-axis" as the gravity direction. But physics allows any direction so we