diff --git a/source/isaaclab/config/extension.toml b/source/isaaclab/config/extension.toml index f33f3f354b6..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.48.0" +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 28dc76731f8..4a638f19609 100644 --- a/source/isaaclab/docs/CHANGELOG.rst +++ b/source/isaaclab/docs/CHANGELOG.rst @@ -1,6 +1,20 @@ Changelog --------- +0.49.0 (2025-11-07) +~~~~~~~~~~~~~~~~~~~ + +Added +^^^^^ + +* 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. + + 0.48.0 (2025-11-03) ~~~~~~~~~~~~~~~~~~~ diff --git a/source/isaaclab/isaaclab/sim/simulation_cfg.py b/source/isaaclab/isaaclab/sim/simulation_cfg.py index 380dba26c51..322c0fe84af 100644 --- a/source/isaaclab/isaaclab/sim/simulation_cfg.py +++ b/source/isaaclab/isaaclab/sim/simulation_cfg.py @@ -180,6 +180,18 @@ 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. + """ + @configclass class RenderCfg: diff --git a/source/isaaclab/isaaclab/sim/simulation_context.py b/source/isaaclab/isaaclab/sim/simulation_context.py index 83277635acf..fb39ec63329 100644 --- a/source/isaaclab/isaaclab/sim/simulation_context.py +++ b/source/isaaclab/isaaclab/sim/simulation_context.py @@ -793,6 +793,22 @@ def _set_additional_physx_params(self): 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 + ) + # -- Gravity # note: Isaac sim only takes the "up-axis" as the gravity direction. But physics allows any direction so we # need to convert the gravity vector to a direction and magnitude pair explicitly. diff --git a/source/isaaclab/test/sim/test_simulation_context.py b/source/isaaclab/test/sim/test_simulation_context.py index f0f783463d2..ea303c74331 100644 --- a/source/isaaclab/test/sim/test_simulation_context.py +++ b/source/isaaclab/test/sim/test_simulation_context.py @@ -146,3 +146,57 @@ 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.""" + + # 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.""" + + # 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)