Repository navigation
Add opt-in live OVD recording to OVPhysX #9194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a6e84c7
a86d45b
cb38624
05eb370
23ac136
9e93f6a
f5b7d83
f9a6e2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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``. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -311,11 +311,48 @@ def transforms(self) -> SceneDataFormat.Transform: | |
| return self._transforms.data | ||
|
|
||
|
|
||
| def _read_ovd_recording_capability() -> bool: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kept the two helpers beside |
||
| 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: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| 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: | ||
|
|
@@ -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 | ||
|
|
@@ -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, | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 withovd-inspect summary. Updated guide · Answers on capture scheduling and inspection · Cartpole launch check