Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ Guidelines for modifications:
* Ori Gadot
* Oyindamola Omotuyi
* Özhan Özen
* Pablo de Heras Ciechomski
* Patrick Yin
* Patrick-SCH03
* Paul Reeves
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions docs/source/concepts/physics-backends/ovphysx.rst

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's also update this Docs page, which has a OVD recording section
https://isaac-sim.github.io/IsaacLab/main/source/how-to/record_animation.html

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the animation guide. Both Isaac Sim Cartpole examples now include --viz kit. The kit-less section links to the runnable start/stop example and shows how to inspect a raw capture with ovd-inspect summary. Updated guide · Answers on capture scheduling and inspection · Cartpole launch check

Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,77 @@ readiness predicate for the current simulation context. Manager teardown release
and clears this handle. Initialize and reset the current context before access, and always
reacquire the handle before creating new bindings or views.

Record OVD during a running simulation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Set ``OvPhysxCfg(ovd_recording_capable=True)`` before the first native PhysX
instance is created. The default is ``False``. Enabling capability provisions
recording resources and can affect simulation performance while output is
inactive. An explicit start selects the destination and begins recording. See
the `OVPhysX recording guide <https://nvidia-omniverse.github.io/PhysX/ovphysx/0.8.0/tutorials/omnipvd_recording.html>`_
for the runtime's recording and performance details.

The manager's handle is ``None`` until the first hard reset starts constructing
the runtime. For recording, wait until that reset has returned and the scene has
attached and warmed up. A late start snapshots the current scene. Run the
start and stop calls on the simulation's stepping thread between completed
steps. The same simulation can continue stepping after a stop and start
another capture with a new destination.

.. image:: ../../_static/concepts/ovphysx-live-ovd-recording.png
:alt: The simulation keeps stepping before, between, and after two separate OVD captures.

This headless example takes several steps before starting a file capture.

.. code-block:: python

from ovphysx import OmniPvdDestination
from pxr import UsdGeom, UsdPhysics

from isaaclab.sim import SimulationCfg, build_simulation_context
from isaaclab_ov.physics import OvPhysxCfg

cfg = SimulationCfg(device="cpu", physics=OvPhysxCfg(ovd_recording_capable=True))
with build_simulation_context(sim_cfg=cfg) as sim:
cube = UsdGeom.Cube.Define(sim.stage, "/World/Cube")
cube.AddTranslateOp().Set((0.0, 0.0, 2.0))
UsdPhysics.RigidBodyAPI.Apply(cube.GetPrim())
UsdPhysics.CollisionAPI.Apply(cube.GetPrim())
sim.reset()

for _ in range(10):
sim.step(render=False)

physx = sim.backend_manager.get_physx_instance()
physx.start_recording(OmniPvdDestination.file("captures/late.ovd"))
try:
for _ in range(20):
sim.step(render=False)
finally:
physx.stop_recording()

for _ in range(10):
sim.step(render=False)

A path ending in lowercase ``.ovd`` selects that filename and can replace an
existing file. A directory destination produces timestamped files and preserves
existing captures. For streaming, use ``OmniPvdDestination.tcp(address, port,
timeout_ms=...)`` with an already listening, trusted receiver. Starting a
TCP capture connects synchronously.

The process can have one active recording at a time. Stop it on the native
instance that started it. A forced re-warm that reloads the stage or a context
close ends its capture without restarting it. Stop explicitly before teardown
to receive recording errors, and reacquire the native handle in a new context.

The capability setting is shared process-wide and the native value persists
after the context closes. A default Isaac Lab context resets an unfrozen
``True`` to ``False``, including a value set directly through the SDK, retained
from an earlier job, or inherited from host settings. A default context raises
if an existing capable runtime has frozen the value. Match that runtime's
capability, complete native shutdown by closing all owners, or run the new
context in a fresh process with the desired value.

Reuse Isaac Lab-owned access
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Added opt-in ``ovd_recording_capable`` to :class:`~isaaclab_ov.physics.OvPhysxCfg` for
live OVD start and stop with the native OVPhysX handle.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Default OVPhysX contexts set an unfrozen recording capability to ``False``, including values
set by the native SDK, retained from an earlier job, or inherited from host settings. They raise
a configuration error when a live native runtime has already frozen capability to ``True``.
55 changes: 54 additions & 1 deletion source/isaaclab_ov/isaaclab_ov/physics/ovphysx_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,48 @@ def transforms(self) -> SceneDataFormat.Transform:
return self._transforms.data


def _read_ovd_recording_capability() -> bool:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Style Consistency — Move private helpers after classes

The two private functions interrupt public class declarations, contrary to the prescribed module order. Move them below the public classes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the two helpers beside OvPhysxBackend, their only caller. The module already has top-level private helpers before its classes, and the contribution guide's ordering rule is for class members.

try:
value = ovphysx.get_global_config(ovphysx.GlobalConfigKey.OVD_RECORDING_CAPABLE)
except (AttributeError, RuntimeError, ValueError) as exc:
raise RuntimeError(
"Cannot read ovd_recording_capable from OVPhysX. The supported runtime is ovphysx==0.8.0.43443703471."
) from exc
if not isinstance(value, bool):
raise RuntimeError(
f"OVPhysX returned {value!r} for ovd_recording_capable. "
"The supported runtime is ovphysx==0.8.0.43443703471."
)
return value


def _ovd_recording_capability_conflict(requested: bool, configured: bool) -> str:
return (
f"OVPhysX ovd_recording_capable={requested} conflicts with the process configuration ({configured}). "
"Set ovd_recording_capable to match it, close all native owners and complete runtime shutdown, "
"or start a new process with the desired value."
)


class OvPhysxBackend:
"""Own the native OVPhysX runtime and either own or borrow its stage."""

def __init__(self, cfg: OvPhysxBackendCfg, *, scene: OvstageBackend | None = None):
requested = cfg.ovd_recording_capable
if not isinstance(requested, bool):
raise TypeError("ovd_recording_capable must be a bool.")
ovphysx.bootstrap()
configured = _read_ovd_recording_capability()
# The setting survives shutdown, but the setter is frozen while the native runtime is live.
if configured != requested:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Compatibility — Preserve inherited recording capability

An omitted option now disables SDK-configured recording or rejects a live capable runtime. Preserve inheritance through a warned, documented deprecation transition; validate both omitted and explicit settings.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicit startup opt-in is the product contract for this PR. An omitted option requests False. That restores an unfrozen SDK setting to False, and a live owner with a conflicting value causes an explicit startup error. The regression suite covers both the default and the live conflict. CI job

try:
ovphysx.set_global_config(ovphysx.GlobalConfigKey.OVD_RECORDING_CAPABLE, requested)
except AttributeError as exc:
raise RuntimeError(
"Cannot set ovd_recording_capable on OVPhysX. The supported runtime is ovphysx==0.8.0.43443703471."
) from exc
except (RuntimeError, ValueError) as exc:
raise RuntimeError(_ovd_recording_capability_conflict(requested, configured)) from exc
is_gpu = cfg.device.startswith("cuda:")
cache_dir = cfg.cooked_collider_cache_dir
if cache_dir == DEFAULT_COOKED_COLLIDER_CACHE_DIR:
Expand All @@ -331,12 +368,27 @@ def __init__(self, cfg: OvPhysxBackendCfg, *, scene: OvstageBackend | None = Non
carbonite_overrides.update({"/physics/suppressReadback": True, "/physics/suppressFabricUpdate": True})
# CPU scenes select CPU dynamics through their scene attributes (see _set_scene_dynamics_device).
# OVPhysX's process-wide CPU-only mode is irreversible and would block later CUDA scenes.
self.physx = ovphysx.PhysX(
physx = ovphysx.PhysX(
config=ovphysx.PhysXConfig(
num_threads=8, cooked_collider_cache_dir=cache_dir, carbonite_overrides=carbonite_overrides
),
active_cuda_gpus=cfg.device.removeprefix("cuda:") if is_gpu else None,
)
try:
# Another native owner may have selected the configuration before construction completed.
configured = _read_ovd_recording_capability()
if configured != requested:
raise RuntimeError(_ovd_recording_capability_conflict(requested, configured))
except Exception as startup_error:
try:
physx.destroy()
except Exception as cleanup_error:
startup_error.add_note(
"OVPhysX could not confirm candidate cleanup. If native ownership remains, start a new process."
)
raise startup_error from cleanup_error
raise
self.physx = physx
self.scene = scene
self.owns_scene = scene is None
self.stage: Any = None
Expand Down Expand Up @@ -791,6 +843,7 @@ def _warmup_and_load(self) -> None:
OvPhysxBackendCfg(
device=self._device,
cooked_collider_cache_dir=self._cfg.cooked_collider_cache_dir,
ovd_recording_capable=self._cfg.ovd_recording_capable,
),
scene=shared_scene,
)
Expand Down
10 changes: 10 additions & 0 deletions source/isaaclab_ov/isaaclab_ov/physics/ovphysx_manager_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class OvPhysxBackendCfg(BackendCfg):
cooked_collider_cache_dir: str | None = DEFAULT_COOKED_COLLIDER_CACHE_DIR
"""Cooked-collider cache location, fixed by the first runtime created in the process."""

ovd_recording_capable: bool = False
"""Provision process-wide OVD recording capability before the first native instance."""


@configclass
class OvPhysxCfg(PhysicsCfg):
Expand Down Expand Up @@ -82,6 +85,13 @@ class OvPhysxCfg(PhysicsCfg):
This does not disable the cooked-collider cache.
"""

ovd_recording_capable: bool = field(default=False, kw_only=True)
"""Provision OVD recording capability at startup, without starting a capture.

This is shared by all native OVPhysX instances in a process. Changing it
requires full native runtime shutdown before creating the next instance.
"""

enable_enhanced_determinism: bool = False
"""Enable/disable improved determinism at the expense of performance. Defaults to False.

Expand Down
Loading
Loading