Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 @@ -182,6 +182,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.
73 changes: 73 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 @@ -341,6 +341,79 @@ 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.

.. _ovphysx-live-ovd-recording:

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
61 changes: 44 additions & 17 deletions docs/source/how-to/record_animation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Recording Animations of Simulations

.. currentmodule:: isaaclab

Use Newton RTX to record simulation videos without Isaac Sim. The Kit-based USD animation
workflows are retained below for existing projects.
Use Newton RTX to record simulation videos or kit-less OVPhysX to capture live physics data.
Existing projects can also use the Kit recorders to export USD animations.

Newton RTX video recording
---------------------------
Expand All @@ -32,8 +32,7 @@ Isaac Sim / Kit USD animation (deprecated)
workflows. The Stage Recorder and OVD instructions below remain available for projects that
need their USD animation outputs.

Isaac Lab supports two approaches for recording animations of physics simulations: the **Stage Recorder** and the **OVD Recorder**.
Both generate USD outputs that can be played back in Omniverse, but they differ in how they work and when you’d use them.
The **Stage Recorder** and the **Isaac Sim OVD Recorder** generate USD animations for playback in Omniverse.

The `Stage Recorder`_ extension listens to all motion and USD property changes in the stage during simulation
and records them as **time-sampled data**. The result is a USD file that captures only the animated changes—**not** the
Expand All @@ -44,8 +43,8 @@ This method is built into Isaac Lab’s UI through the :class:`~isaaclab.envs.ui
However, to record the animation of a simulation, you need to disable `Fabric`_ to allow reading and writing
all the changes (such as motion and USD properties) to the USD stage.

The **OVD Recorder** is designed for more scalable or automated workflows. It uses OmniPVD to capture simulated physics from a played stage
and then **bakes** that directly into an animated USD file. It works with Fabric enabled and runs with CLI arguments.
The **Isaac Sim OVD Recorder** uses OmniPVD to capture simulated physics and bake it into an animated USD file.
It works with Fabric enabled and runs with CLI arguments.
The animated USD can be quickly replayed and reviewed by scrubbing through the timeline window, without simulating expensive physics operations.

.. note::
Expand Down Expand Up @@ -123,20 +122,15 @@ See the `tutorial on layering in Omniverse`_ for more on working with layers.
OVD Recorder
~~~~~~~~~~~~

The OVD Recorder uses OmniPVD to record simulation data and bake it directly into a new USD stage.
This method is more scalable and better suited for large-scale training scenarios (e.g. multi-env RL).

It’s not UI-controlled—the whole process is enabled through CLI flags and runs automatically.
The animation recording CLI uses the Isaac Sim PhysX backend to capture a single interval and bake it
into a new USD stage. Use ``--viz kit`` to open a window and leave ``HEADLESS`` unset or set to ``0``.

.. note::

The OVD Recorder uses OmniPVD, which only records **PhysX** simulations. If the active physics backend is not
PhysX (for example, Newton, which is the default for many tasks), Isaac Lab raises an error at startup naming
the active backend instead of recording. Select the PhysX backend by adding ``physics=isaacsim_physx`` to the
command line, as shown below.
Select Isaac Sim PhysX by adding ``physics=isaacsim_physx`` to the command line, as shown below.
Kit-less OVPhysX uses the live capture API described below.

The PhysX backend requires Isaac Sim. If it isn't installed yet, add ``--extra isaacsim`` to the ``uv run``
command; see :ref:`installation-optional-extras` for details.
The examples include the Isaac Sim extra. See :ref:`installation-optional-extras` for details.


Workflow Summary
Expand Down Expand Up @@ -176,7 +170,8 @@ To record an animation:

.. note::

The provided ``--anim_recording_stop_time`` should be greater than the simulation time.
Set ``--anim_recording_stop_time`` greater than ``--anim_recording_start_time`` and let the process run
through the export.

.. warning::

Expand All @@ -189,6 +184,38 @@ After the stop time is reached, a file will be saved to:
anim_recordings/<timestamp>/baked_animation_recording.usda


Live OVD capture with kit-less OVPhysX
--------------------------------------

Use ``OvPhysxCfg(ovd_recording_capable=True)`` before the first native PhysX instance is created. The
default is ``False``. After the scene's initial reset completes, get the native OVPhysX handle with
``sim.backend_manager.get_physx_instance()``. Call ``start_recording()`` with an OVD destination and
``stop_recording()`` on the stepping thread between completed steps.

For multiple captures in a job, let the simulation code choose when to start and stop each capture.
Only one capture per process can be active at a time. After stopping, the simulation can keep stepping
and start another capture with a different destination. The live API writes OVD data, and the
``--anim_recording_*`` flags are for the Isaac Sim USD-baking workflow above.

See :ref:`ovphysx-live-ovd-recording` for a runnable headless example, destination options, and the
recording lifetime.

Inspect an OVPhysX capture
~~~~~~~~~~~~~~~~~~~~~~~~~~

A live capture is a physics recording for inspection. Use an external reader to examine the file.
With the PhysX SDK's ``ovd-inspect`` tool installed, summarize the recording to find its scenes and
completed frames.

.. code-block:: bash

ovd-inspect summary captures/late.ovd

The `SDK inspection guide <https://nvidia-omniverse.github.io/PhysX/ovphysx/0.8.0/tutorials/omnipvd_recording.html#headless-capture-and-investigation>`_
shows how to inspect an object's recorded values. For visual playback in a compatible Kit application,
enable the OmniPVD extension and follow its `OVD import instructions <https://docs.omniverse.nvidia.com/kit/docs/omni_physics/latest/extensions/ux/source/omni.physx.pvd/docs/dev_guide/physx_visual_debugger.html#loading-an-ovd-file-from-the-file-import-menu>`_.


.. _Stage Recorder: https://docs.omniverse.nvidia.com/extensions/latest/ext_animation_stage-recorder.html
.. _Fabric: https://docs.omniverse.nvidia.com/kit/docs/usdrt.scenegraph/latest/usd_fabric_usdrt.html
.. _Omniverse Launcher: https://docs.omniverse.nvidia.com/launcher/latest/index.html
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