Unverified Commit 9c3db10e authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Adds enhanced determinism flag to PhysxCfg (#395)

# Description

This MR adds an `enableEnhancedDeterminism` flag to have improved
deterministic behavior from the physics engine. By default, this is
False to remain performant. However, it should be set to true for
imitation learning-like applications where you want to replay the
demonstrations.

## Type of change

- New feature (non-breaking change which adds functionality)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have run all the tests with `./orbit.sh --test` and they pass
- [x] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
parent fa175aaf
...@@ -36,6 +36,25 @@ over stepping different parts of the simulation app. However, at this point, the ...@@ -36,6 +36,25 @@ over stepping different parts of the simulation app. However, at this point, the
timeline for this feature request. timeline for this feature request.
Non-determinism in physics simulation
-------------------------------------
Due to GPU work scheduling, there's a possibility that runtime changes to simulation parameters
may alter the order in which operations take place. This occurs because environment updates can
happen while the GPU is occupied with other tasks. Due to the inherent nature of floating-point
numeric storage, any modification to the execution ordering can result in minor changes in the
least significant bits of output data. These changes may lead to divergent execution over the
course of simulating thousands of environments and simulation frames.
An illustrative example of this issue is observed with the runtime domain randomization of object's
physics materials. This process can introduce both determinancy and simulation issues when executed
on the GPU due to the way these parameters are passed from the CPU to the GPU in the lower-level APIs.
Consequently, it is strongly advised to perform this operation only at setup time, before the
environment stepping commences.
For more information, please refer to the `PhysX Determinism documentation`_.
Blank initial frames from the camera Blank initial frames from the camera
------------------------------------ ------------------------------------
...@@ -70,3 +89,4 @@ are stored in the instanceable asset's USD file and not in its stage reference's ...@@ -70,3 +89,4 @@ are stored in the instanceable asset's USD file and not in its stage reference's
.. _instanceable assets: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/tutorial_gym_instanceable_assets.html .. _instanceable assets: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/tutorial_gym_instanceable_assets.html
.. _Omniverse Isaac Sim documentation: https://docs.omniverse.nvidia.com/isaacsim/latest/known_issues.html .. _Omniverse Isaac Sim documentation: https://docs.omniverse.nvidia.com/isaacsim/latest/known_issues.html
.. _PhysX Determinism documentation: https://nvidia-omniverse.github.io/PhysX/physx/5.3.1/docs/BestPractices.html#determinism
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.10.19" version = "0.10.20"
# Description # Description
title = "ORBIT framework for Robot Learning" title = "ORBIT framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.10.20 (2024-02-12)
~~~~~~~~~~~~~~~~~~~~
Added
^^^^^
* Adds :attr:`omni.isaac.orbit.sim.PhysxCfg.enable_enhanced_determinism` to enable improved
determinism from PhysX. Please note this comes at the expense of performance.
0.10.19 (2024-02-08) 0.10.19 (2024-02-08)
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
......
...@@ -114,6 +114,14 @@ class PhysxCfg: ...@@ -114,6 +114,14 @@ class PhysxCfg:
enable_stabilization: bool = True enable_stabilization: bool = True
"""Enable/disable additional stabilization pass in solver. Default is True.""" """Enable/disable additional stabilization pass in solver. Default is True."""
enable_enhanced_determinism: bool = False
"""Enable/disable improved determinism at the expense of performance. Defaults to False.
For more information on PhysX determinism, please check `here`_.
.. _here: https://nvidia-omniverse.github.io/PhysX/physx/5.3.1/docs/RigidBodyDynamics.html#enhanced-determinism
"""
bounce_threshold_velocity: float = 0.5 bounce_threshold_velocity: float = 0.5
"""Relative velocity threshold for contacts to bounce (in m/s). Default is 0.5 m/s.""" """Relative velocity threshold for contacts to bounce (in m/s). Default is 0.5 m/s."""
......
...@@ -484,6 +484,8 @@ class SimulationContext(_SimulationContext): ...@@ -484,6 +484,8 @@ class SimulationContext(_SimulationContext):
self._physics_context.enable_ccd(self.cfg.physx.enable_ccd) self._physics_context.enable_ccd(self.cfg.physx.enable_ccd)
# -- GPU collision stack size # -- GPU collision stack size
physx_scene_api.CreateGpuCollisionStackSizeAttr(self.cfg.physx.gpu_collision_stack_size) physx_scene_api.CreateGpuCollisionStackSizeAttr(self.cfg.physx.gpu_collision_stack_size)
# -- Improved determinism by PhysX
physx_scene_api.CreateEnableEnhancedDeterminismAttr(self.cfg.physx.enable_enhanced_determinism)
# -- Gravity # -- Gravity
# note: Isaac sim only takes the "up-axis" as the gravity direction. But physics allows any direction so we # note: Isaac sim only takes the "up-axis" as the gravity direction. But physics allows any direction so we
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment