-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add perspective video recording via Newton GL viewer for Kitless backends; Fix for Kitfull backends camera position #5011
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
Open
bdilinila
wants to merge
8
commits into
isaac-sim:develop
Choose a base branch
from
bdilinila:dev/bdilinila/kitless-perspective-recording
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+604
−83
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b38944a
Add perspective video recording via Newton GL viewer and Kit Omnivers…
bdilinila 7b58ead
Fix Kit perspective recorder camera targeting
bdilinila 7e22609
Moved recording code-paths to respective backend folders
bdilinila 4fa37f2
Merge branch 'develop' into dev/bdilinila/kitless-perspective-recording
ooctipus 3fb7186
Sync perspective video camera from ViewerCfg
bdilinila 8170dca
Comment fixes: test file moved, self.video_recorder instantiation, Im…
bdilinila 58eb1da
comment fix: VideoRecorder and config classes' field renames
bdilinila a32adfe
Merge branch 'develop' into dev/bdilinila/kitless-perspective-recording
kellyguo11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| # Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| """Video recorder implementation. | ||
|
|
||
| Captures a single wide-angle perspective view of the scene: | ||
|
|
||
| * **Kit backends** (PhysX physics or Isaac RTX renderer) — uses | ||
| :mod:`isaaclab_physx.video_recording.isaacsim_kit_perspective_video`. | ||
| * **Newton backends** (Newton physics or Newton Warp renderer only) — uses | ||
| :mod:`isaaclab_newton.video_recording.newton_gl_perspective_video`. | ||
|
|
||
| If neither a Kit nor a Newton backend is detected, construction raises so users do not | ||
| use ``--video`` on unsupported setups. | ||
|
|
||
| See :mod:`video_recorder_cfg` for configuration. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| from typing import TYPE_CHECKING, Literal | ||
|
|
||
| import numpy as np | ||
|
|
||
| if TYPE_CHECKING: | ||
| from isaaclab.scene import InteractiveScene | ||
|
|
||
| from .video_recorder_cfg import VideoRecorderCfg | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| _VideoBackend = Literal["kit", "newton_gl"] | ||
|
|
||
|
|
||
| def _resolve_video_backend(scene: InteractiveScene) -> _VideoBackend: | ||
| """Resolve which video backend to use from physics and renderer configs. | ||
|
|
||
| Priority: PhysX or Isaac RTX -> Kit camera; else Newton or Newton Warp -> GL viewer. | ||
| When both are present (e.g. PhysX + Newton Warp), Kit wins. | ||
| """ | ||
| sim = scene.sim | ||
| physics_name = sim.physics_manager.__name__.lower() | ||
| renderer_types: list[str] = scene._sensor_renderer_types() | ||
|
|
||
| use_kit = "physx" in physics_name or "isaac_rtx" in renderer_types | ||
| use_newton_gl = "newton" in physics_name or "newton_warp" in renderer_types | ||
|
|
||
| if use_kit: | ||
| return "kit" | ||
| if use_newton_gl: | ||
| return "newton_gl" | ||
| raise RuntimeError( | ||
| "Video recording (--video) requires a supported backend: " | ||
| "PhysX or Isaac RTX renderer (Kit camera), or Newton physics / Newton Warp renderer (GL viewer). " | ||
| "No supported backend detected; do not use --video for this setup." | ||
| ) | ||
|
|
||
|
|
||
| class VideoRecorder: | ||
| """Records perspective video frames from the scene's active renderer. | ||
|
|
||
| Args: | ||
| cfg: Recorder configuration. | ||
| scene: The interactive scene that owns the sensors. | ||
| """ | ||
|
|
||
| def __init__(self, cfg: VideoRecorderCfg, scene: InteractiveScene): | ||
| self.cfg = cfg | ||
| self._scene = scene | ||
| self._backend: _VideoBackend | None = None | ||
| self._capture = None | ||
|
|
||
| if cfg.env_render_mode == "rgb_array": | ||
| self._backend = _resolve_video_backend(scene) | ||
| if self._backend == "newton_gl": | ||
| try: | ||
| import pyglet | ||
|
|
||
| if not pyglet.options.get("headless", False): | ||
| pyglet.options["headless"] = True | ||
| except ImportError as e: | ||
| raise ImportError( | ||
| "The Newton GL video backend requires 'pyglet'. Install IsaacLab with './isaaclab.sh -i'." | ||
| ) from e | ||
| from isaaclab_newton.video_recording.newton_gl_perspective_video import ( | ||
| create_newton_gl_perspective_video, | ||
| ) | ||
| from isaaclab_newton.video_recording.newton_gl_perspective_video_cfg import NewtonGlPerspectiveVideoCfg | ||
|
|
||
| ncfg = NewtonGlPerspectiveVideoCfg( | ||
| window_width=cfg.window_width, | ||
| window_height=cfg.window_height, | ||
| camera_position=cfg.camera_position, | ||
| camera_target=cfg.camera_target, | ||
| ) | ||
| self._capture = create_newton_gl_perspective_video(ncfg) | ||
| else: | ||
| from isaaclab_physx.video_recording.isaacsim_kit_perspective_video import ( | ||
| create_isaacsim_kit_perspective_video, | ||
| ) | ||
| from isaaclab_physx.video_recording.isaacsim_kit_perspective_video_cfg import ( | ||
| IsaacsimKitPerspectiveVideoCfg, | ||
| ) | ||
|
|
||
| kcfg = IsaacsimKitPerspectiveVideoCfg( | ||
| camera_position=cfg.camera_position, | ||
| camera_target=cfg.camera_target, | ||
| window_width=cfg.window_width, | ||
| window_height=cfg.window_height, | ||
| ) | ||
| self._capture = create_isaacsim_kit_perspective_video(kcfg) | ||
|
|
||
| def render_rgb_array(self) -> np.ndarray | None: | ||
| """Return an RGB frame for the resolved backend. Fails if backend is unavailable.""" | ||
| if self._backend is None or self._capture is None: | ||
| return None | ||
| return self._capture.render_rgb_array() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.