-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Adds disable sleeping global flag for physx #3975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR adds two new PhysX configuration parameters to improve simulation control and consistency:
disable_sleeping(default: True): Disables sleeping globally to ensure consistent behavior between CPU and GPU simulation pipelines, as GPU doesn't support sleeping in PhysXenable_external_forces_every_iteration(default: False): Applies external forces in lockstep with TGS solver iterations to reduce noisy joint velocity data at minor performance cost (~4%)
Key Changes:
- Configuration flags added to
PhysxCfgwith comprehensive documentation - Implementation in
simulation_context.pywith GPU pipeline validation - Comprehensive test coverage for both flags including error cases
- CHANGELOG and version bump (0.47.11 → 0.49.0) reflecting breaking change
- Runtime validation prevents incompatible
disable_sleeping=False+ GPU pipeline configuration
Breaking Change:
The default disable_sleeping=True changes existing behavior. Users who need sleeping on CPU must explicitly set this to False.
Confidence Score: 4/5
- This PR is safe to merge with minor style improvement recommended
- The implementation is solid with comprehensive tests and documentation. Score of 4 (not 5) due to: (1) validation happens after attribute is set, though exception prevents scene creation, and (2) this is a breaking change that alters default behavior. The feature itself is well-designed and addresses real user needs (CPU/GPU consistency and joint velocity noise).
- Pay attention to
simulation_context.py- consider reordering validation before attribute setting
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| source/isaaclab/isaaclab/sim/simulation_cfg.py | 5/5 | Added disable_sleeping (default True) and enable_external_forces_every_iteration (default False) flags with clear documentation |
| source/isaaclab/isaaclab/sim/simulation_context.py | 4/5 | Implements the two new PhysX settings with GPU pipeline validation; attribute is set before validation check |
| source/isaaclab/test/sim/test_simulation_context.py | 5/5 | Added comprehensive tests covering default behavior, CPU/GPU configurations, and error handling for both new PhysX flags |
Sequence Diagram
sequenceDiagram
participant User
participant SimulationCfg
participant SimulationContext
participant ParentContext
participant CarbSettings
participant PhysXScene
User->>SimulationCfg: Create config with device="cuda:0"
Note over SimulationCfg: disable_sleeping=True (default)<br/>enable_external_forces_every_iteration=False (default)
User->>SimulationContext: __init__(cfg)
SimulationContext->>ParentContext: super().__init__(device=cfg.device)
ParentContext->>CarbSettings: Set /physics/suppressReadback=True
Note over CarbSettings: GPU pipeline enabled
SimulationContext->>SimulationContext: _apply_physics_settings()
Note over SimulationContext: Configure carb physics settings
SimulationContext->>SimulationContext: _initialize_stage()
SimulationContext->>SimulationContext: _set_additional_physx_params()
SimulationContext->>PhysXScene: CreateAttribute("physxSceneAPI:disableSleeping")
SimulationContext->>PhysXScene: Set(disable_sleeping=True)
alt disable_sleeping is False
SimulationContext->>CarbSettings: get_as_bool("/physics/suppressReadback")
CarbSettings-->>SimulationContext: suppressReadback=True
SimulationContext-->>User: RuntimeError: GPU pipeline incompatible
else disable_sleeping is True
Note over SimulationContext: Validation passed
end
SimulationContext->>PhysXScene: CreateEnableExternalForcesEveryIterationAttr()
SimulationContext->>PhysXScene: Set(enable_external_forces_every_iteration)
SimulationContext-->>User: Simulation ready
5 files reviewed, 1 comment
Signed-off-by: Kelly Guo <[email protected]>
Signed-off-by: Kelly Guo <[email protected]>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Kelly Guo <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR introduces two new PhysX configuration flags for better simulation control:
Key Changes:
disable_sleeping: New flag (default:True) that globally disables sleeping for all physics objects, overriding per-object settings. This ensures consistent behavior between CPU and GPU simulation pipelines, as sleeping is not supported on GPU. The implementation includes validation that prevents the invalid configuration ofdisable_sleeping=Falsewith GPU pipeline enabled.enable_external_forces_every_iteration: New TGS solver flag (default:False) that applies external forces in lockstep with every solver iteration. When enabled, reduces noisy joint velocity data at ~4% performance cost.
Implementation Quality:
- Proper error handling with clear, actionable error messages
- Validation logic correctly prevents PhysX scene creation failures
- Comprehensive test coverage including edge cases (CPU-only, GPU error conditions)
- Good documentation in config class explaining behavior and trade-offs
- Breaking change is well-documented (default
disable_sleeping=Truechanges behavior for users who relied on sleeping)
Architecture:
The changes are localized to the simulation context setup, adding configuration in PhysxCfg and applying settings during physics scene initialization. The validation occurs before setting USD attributes, preventing invalid states.
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The implementation is well-designed with proper validation, comprehensive testing, and clear documentation. The validation logic correctly prevents invalid GPU+sleeping configurations before they cause runtime failures. Tests cover all important scenarios including defaults, CPU/GPU differences, and error conditions.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| source/isaaclab/isaaclab/sim/simulation_context.py | 5/5 | Added two new PhysX flags: disable_sleeping (with GPU validation) and enable_external_forces_every_iteration. Implementation is correct with proper error handling. |
| source/isaaclab/test/sim/test_simulation_context.py | 5/5 | Added comprehensive tests for both new flags covering default behavior, CPU/GPU configurations, and error conditions. Tests are thorough and well-structured. |
Sequence Diagram
sequenceDiagram
participant User
participant SimulationCfg
participant SimulationContext
participant PhysxScene
participant CarbSettings
User->>SimulationCfg: Create config with device & physx flags
User->>SimulationContext: Initialize SimulationContext(cfg)
SimulationContext->>SimulationContext: _set_simulation_dt()
SimulationContext->>SimulationContext: Setup PhysX scene
alt disable_sleeping = False
SimulationContext->>CarbSettings: get_as_bool("/physics/suppressReadback")
CarbSettings-->>SimulationContext: GPU pipeline status
alt GPU pipeline enabled
SimulationContext-->>User: RuntimeError (invalid config)
else CPU pipeline
SimulationContext->>PhysxScene: Set physxSceneAPI:disableSleeping = False
end
else disable_sleeping = True
SimulationContext->>PhysxScene: Set physxSceneAPI:disableSleeping = True
end
SimulationContext->>PhysxScene: CreateEnableExternalForcesEveryIterationAttr()
PhysxScene->>PhysxScene: Apply enable_external_forces_every_iteration flag
SimulationContext-->>User: Simulation ready
2 files reviewed, no comments
| message and fail scene creation as this is not supported. | ||
| """ | ||
|
|
||
| enable_external_forces_every_iteration: bool = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this flag only work when TGS is used? Also if this flag is enabled, then within the asset classes, I wonder if we still need to set forces at simulation steps. Previously those were getting cleared which wasn't a desired effect.
By iteration: do you mean solver iteration or sim.step? The document is clear about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on here, this flag is only valid for TGS: https://docs.omniverse.nvidia.com/kit/docs/omni_usd_schema_physics/106.0/class_physx_schema_physx_scene_a_p_i.html#a0a8da8575a2180564cede1ddf4f5ab1a
If the values are more correct, I think we should keep this flag as True by default. Most usecases where sim-to-real is concerned, bad joint velocities affects the deployment. In my experience, many users remove joint velocities from observations because of the jitteriness in the deployed behavior. We should inform the users that if they care about performance, then they can disable these flags to get "approximated" values, but the default should try to remain a "correct" value. |
…Lab-public into feature/physics-updates
|
Keeping external force flag independent in #3989 |
Greptile OverviewGreptile SummaryAdds a global Key Changes:
Implementation Quality: Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant SimulationCfg
participant SimulationContext
participant PhysxPrim
participant CarbSettings
User->>SimulationCfg: Create config with disable_sleeping=True (default)
User->>SimulationContext: Initialize SimulationContext(cfg)
SimulationContext->>SimulationContext: _configure_simulation_flags()
alt disable_sleeping is False
SimulationContext->>CarbSettings: get_as_bool("/physics/suppressReadback")
CarbSettings-->>SimulationContext: Returns GPU pipeline status
alt GPU pipeline enabled (suppressReadback=True)
SimulationContext->>User: RuntimeError: GPU + sleeping not supported
end
end
SimulationContext->>PhysxPrim: CreateAttribute("physxSceneAPI:disableSleeping")
SimulationContext->>PhysxPrim: Set(cfg.physx.disable_sleeping)
PhysxPrim-->>SimulationContext: Attribute applied globally
Note over PhysxPrim: Global sleeping disabled,<br/>overrides per-object settings
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, 2 comments
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Kelly Guo <[email protected]>
Signed-off-by: Kelly Guo <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, 2 comments
Signed-off-by: Kelly Guo <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, no comments
Description
Introducing new PhysxCfg flag disable_sleeping to disable sleeping on a global level. This flag will now override per-object sleeping settings if set to True. If sleeping is desired for any object in the scene, ensure this flag is set to False. We are setting this to True by default to keep a consistent behavior between CPU and GPU simulation, since sleeping is not supported by PhysX on the GPU pipeline. This has also previously caused confusion for some users where the contact forces reported on CPU and GPU simulation were different due to sleeping.
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there