Unverified Commit 849d9b41 authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Changes initialize and invalidate handles to use timeline events (#245)

# Description

This MR changes the `AssetBase` and `SensorBase` classes to use
time-line events instead of physics events for initializing and
invalidating physics-based handles. This is needed for cases where we
have to wait for physics mesh cooking to finish before the handles are
available.

For instance, with the previous code, when trying to initialize the
views for deformable objects, the following error happens:

```bash
2023-11-11 00:18:06 [17,966ms] [Error] [omni.physx.plugin] Cuda context manager error, simulation will be stopped and new cuda context manager will be created.
2023-11-11 00:18:06 [17,966ms] [Error] [omni.physx.plugin] PhysX error: SynchronizeStreams cuStreamWaitEvent failed with error 700
, FILE /buildAgent/work/74336105e89c4a74/source/gpucommon/include/PxgCudaUtils.h, LINE 59
2023-11-11 00:18:06 [17,966ms] [Error] [omni.physx.plugin] Cuda context manager error, simulation will be stopped and new cuda context manager will be created.
2023-11-11 00:18:06 [17,967ms] [Error] [omni.physx.plugin] PhysX error: memcpy failed fail!
  700, FILE /buildAgent/work/74336105e89c4a74/source/gpunarrowphase/src/PxgNarrowphaseCore.cpp, LINE 1444
2023-11-11 00:18:06 [17,967ms] [Error] [omni.physx.plugin] Cuda context manager error, simulation will be stopped and new cuda context manager will be created.
2023-11-11 00:18:06 [17,967ms] [Error] [omni.physx.plugin] PhysX error: GPU clampMaxValues fail to launch kernel!!
, FILE /buildAgent/work/74336105e89c4a74/source/gpusimulationcontroller/src/PxgSoftBodyCore.cpp, LINE 484
2023-11-11 00:18:06 [17,967ms] [Error] [omni.physx.plugin] Cuda context manager error, simulation will be stopped and new cuda context manager will be created.
2023-11-11 00:18:06 [17,968ms] [Error] [omni.physx.plugin] PhysX error: GPU sortSoftBodyContacts fail to launch kernel!!
```

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.sh --format`
- [ ] 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
- [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 b8222335
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.9.42" version = "0.9.43"
# Description # Description
title = "ORBIT framework for Robot Learning" title = "ORBIT framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.9.43 (2023-11-16)
~~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Replaced subscription of physics play and stop events in the :class:`omni.isaac.orbit.assets.AssetBase` and
:class:`omni.isaac.orbit.sensors.SensorBase` classes with subscription to time-line play and stop events.
This is to prevent issues in cases where physics first needs to perform mesh cooking and handles are not
available immediately. For instance, with deformable meshes.
0.9.42 (2023-11-16) 0.9.42 (2023-11-16)
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
......
...@@ -13,7 +13,7 @@ from typing import TYPE_CHECKING, Any, Sequence ...@@ -13,7 +13,7 @@ from typing import TYPE_CHECKING, Any, Sequence
import omni.isaac.core.utils.prims as prim_utils import omni.isaac.core.utils.prims as prim_utils
import omni.kit.app import omni.kit.app
import omni.physx import omni.timeline
if TYPE_CHECKING: if TYPE_CHECKING:
from .asset_base_cfg import AssetBaseCfg from .asset_base_cfg import AssetBaseCfg
...@@ -58,14 +58,14 @@ class AssetBase(ABC): ...@@ -58,14 +58,14 @@ class AssetBase(ABC):
# note: Use weakref on all callbacks to ensure that this object can be deleted when its destructor is called. # note: Use weakref on all callbacks to ensure that this object can be deleted when its destructor is called.
# add callbacks for stage play/stop # add callbacks for stage play/stop
# The order is set to 10 which is arbitrary but should be lower priority than the default order of 0 # The order is set to 10 which is arbitrary but should be lower priority than the default order of 0
physx_event_stream = omni.physx.acquire_physx_interface().get_simulation_event_stream_v2() timeline_event_stream = omni.timeline.get_timeline_interface().get_timeline_event_stream()
self._initialize_handle = physx_event_stream.create_subscription_to_pop_by_type( self._initialize_handle = timeline_event_stream.create_subscription_to_pop_by_type(
int(omni.physx.bindings._physx.SimulationEvent.RESUMED), int(omni.timeline.TimelineEventType.PLAY),
lambda event, obj=weakref.proxy(self): obj._initialize_callback(event), lambda event, obj=weakref.proxy(self): obj._initialize_callback(event),
order=10, order=10,
) )
self._invalidate_initialize_handle = physx_event_stream.create_subscription_to_pop_by_type( self._invalidate_initialize_handle = timeline_event_stream.create_subscription_to_pop_by_type(
int(omni.physx.bindings._physx.SimulationEvent.STOPPED), int(omni.timeline.TimelineEventType.STOP),
lambda event, obj=weakref.proxy(self): obj._invalidate_initialize_callback(event), lambda event, obj=weakref.proxy(self): obj._invalidate_initialize_callback(event),
order=10, order=10,
) )
......
...@@ -19,7 +19,7 @@ from typing import TYPE_CHECKING, Any, Sequence ...@@ -19,7 +19,7 @@ from typing import TYPE_CHECKING, Any, Sequence
import omni.isaac.core.utils.prims as prim_utils import omni.isaac.core.utils.prims as prim_utils
import omni.kit.app import omni.kit.app
import omni.physx import omni.timeline
from omni.isaac.core.simulation_context import SimulationContext from omni.isaac.core.simulation_context import SimulationContext
if TYPE_CHECKING: if TYPE_CHECKING:
...@@ -55,14 +55,14 @@ class SensorBase(ABC): ...@@ -55,14 +55,14 @@ class SensorBase(ABC):
# note: Use weakref on callbacks to ensure that this object can be deleted when its destructor is called. # note: Use weakref on callbacks to ensure that this object can be deleted when its destructor is called.
# add callbacks for stage play/stop # add callbacks for stage play/stop
# The order is set to 10 which is arbitrary but should be lower priority than the default order of 0 # The order is set to 10 which is arbitrary but should be lower priority than the default order of 0
physx_event_stream = omni.physx.acquire_physx_interface().get_simulation_event_stream_v2() timeline_event_stream = omni.timeline.get_timeline_interface().get_timeline_event_stream()
self._initialize_handle = physx_event_stream.create_subscription_to_pop_by_type( self._initialize_handle = timeline_event_stream.create_subscription_to_pop_by_type(
int(omni.physx.bindings._physx.SimulationEvent.RESUMED), int(omni.timeline.TimelineEventType.PLAY),
lambda event, obj=weakref.proxy(self): obj._initialize_callback(event), lambda event, obj=weakref.proxy(self): obj._initialize_callback(event),
order=10, order=10,
) )
self._invalidate_initialize_handle = physx_event_stream.create_subscription_to_pop_by_type( self._invalidate_initialize_handle = timeline_event_stream.create_subscription_to_pop_by_type(
int(omni.physx.bindings._physx.SimulationEvent.STOPPED), int(omni.timeline.TimelineEventType.STOP),
lambda event, obj=weakref.proxy(self): obj._invalidate_initialize_callback(event), lambda event, obj=weakref.proxy(self): obj._invalidate_initialize_callback(event),
order=10, order=10,
) )
......
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