Skip to content

Commit

Permalink
Changes initialize and invalidate handles to use timeline events (#245)
Browse files Browse the repository at this point in the history
# 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
  • Loading branch information
Mayankm96 authored Nov 16, 2023
1 parent b822233 commit 849d9b4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion source/extensions/omni.isaac.orbit/config/extension.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

# Note: Semantic Versioning is used: https://semver.org/
version = "0.9.42"
version = "0.9.43"

# Description
title = "ORBIT framework for Robot Learning"
Expand Down
12 changes: 12 additions & 0 deletions source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
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)
~~~~~~~~~~~~~~~~~~~

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import omni.isaac.core.utils.prims as prim_utils
import omni.kit.app
import omni.physx
import omni.timeline

if TYPE_CHECKING:
from .asset_base_cfg import AssetBaseCfg
Expand Down Expand Up @@ -58,14 +58,14 @@ def __init__(self, cfg: AssetBaseCfg):
# 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
# 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()
self._initialize_handle = physx_event_stream.create_subscription_to_pop_by_type(
int(omni.physx.bindings._physx.SimulationEvent.RESUMED),
timeline_event_stream = omni.timeline.get_timeline_interface().get_timeline_event_stream()
self._initialize_handle = timeline_event_stream.create_subscription_to_pop_by_type(
int(omni.timeline.TimelineEventType.PLAY),
lambda event, obj=weakref.proxy(self): obj._initialize_callback(event),
order=10,
)
self._invalidate_initialize_handle = physx_event_stream.create_subscription_to_pop_by_type(
int(omni.physx.bindings._physx.SimulationEvent.STOPPED),
self._invalidate_initialize_handle = timeline_event_stream.create_subscription_to_pop_by_type(
int(omni.timeline.TimelineEventType.STOP),
lambda event, obj=weakref.proxy(self): obj._invalidate_initialize_callback(event),
order=10,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import omni.isaac.core.utils.prims as prim_utils
import omni.kit.app
import omni.physx
import omni.timeline
from omni.isaac.core.simulation_context import SimulationContext

if TYPE_CHECKING:
Expand Down Expand Up @@ -55,14 +55,14 @@ def __init__(self, cfg: SensorBaseCfg):
# note: Use weakref on callbacks to ensure that this object can be deleted when its destructor is called.
# 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
physx_event_stream = omni.physx.acquire_physx_interface().get_simulation_event_stream_v2()
self._initialize_handle = physx_event_stream.create_subscription_to_pop_by_type(
int(omni.physx.bindings._physx.SimulationEvent.RESUMED),
timeline_event_stream = omni.timeline.get_timeline_interface().get_timeline_event_stream()
self._initialize_handle = timeline_event_stream.create_subscription_to_pop_by_type(
int(omni.timeline.TimelineEventType.PLAY),
lambda event, obj=weakref.proxy(self): obj._initialize_callback(event),
order=10,
)
self._invalidate_initialize_handle = physx_event_stream.create_subscription_to_pop_by_type(
int(omni.physx.bindings._physx.SimulationEvent.STOPPED),
self._invalidate_initialize_handle = timeline_event_stream.create_subscription_to_pop_by_type(
int(omni.timeline.TimelineEventType.STOP),
lambda event, obj=weakref.proxy(self): obj._invalidate_initialize_callback(event),
order=10,
)
Expand Down

0 comments on commit 849d9b4

Please sign in to comment.