-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Pre and post physics renderer initialization #5573
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
Merged
pbarejko
merged 7 commits into
isaac-sim:develop
from
pbarejko:pbarejko/init-renderer-first
May 12, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
50cf5f0
Pre-Initialize renderers
pbarejko 8efb9a1
Re-format
pbarejko 22376d1
Update changelog
pbarejko f91c00d
Swap assert to runtime error
pbarejko d3473f0
rename ovrtx initialize to _initialize_from_spec
pbarejko 33c9f60
post physics initialization
pbarejko 022868e
Fix end of file
pbarejko 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
31 changes: 31 additions & 0 deletions
31
source/isaaclab/changelog.d/scene-initialize-renderers.minor.rst
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,31 @@ | ||
| Added | ||
| ^^^^^ | ||
|
|
||
| * Added :meth:`~isaaclab.scene.InteractiveScene.initialize_renderers` to | ||
| pre-create renderer backends for all scene sensors with a | ||
| ``renderer_cfg`` against the shared | ||
| :class:`~isaaclab.renderers.render_context.RenderContext`. The method is | ||
| idempotent and is now invoked from | ||
| :class:`~isaaclab.envs.DirectRLEnv`, | ||
| :class:`~isaaclab.envs.DirectMARLEnv`, | ||
| :class:`~isaaclab.envs.ManagerBasedEnv`, and | ||
| :class:`~isaaclab.envs.LeappDeploymentEnv` after scene construction so | ||
| that renderer backend creation order is deterministic and front-loaded | ||
| before the first :meth:`~isaaclab.sim.SimulationContext.reset`. | ||
| * Added :meth:`~isaaclab.renderers.base_renderer.BaseRenderer.initialize` | ||
| post-physics lifecycle hook (default no-op) that runs once per backend | ||
| after :meth:`~isaaclab.sim.SimulationContext.reset` builds physics | ||
| models. ``__init__`` now defines the pre-physics phase (eagerly invoked | ||
| by :meth:`~isaaclab.scene.InteractiveScene.initialize_renderers`) and | ||
| ``initialize`` defines the post-physics phase, letting backends whose | ||
| setup needs scene data (e.g. a built Newton model) defer that work | ||
| cleanly. Driven by | ||
| :meth:`~isaaclab.renderers.render_context.RenderContext.ensure_initialize`, | ||
| registered on | ||
| :class:`~isaaclab.physics.physics_manager.PhysicsEvent` ``PHYSICS_READY`` | ||
| by :class:`~isaaclab.sim.SimulationContext` at ``order=5`` so it fires | ||
| before sensor/asset callbacks (``order=10``). This decouples renderer | ||
| post-physics setup from camera initialization. Backends created lazily | ||
| after PHYSICS_READY are eagerly initialized at | ||
| :meth:`~isaaclab.renderers.render_context.RenderContext.get_renderer` | ||
| time. |
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
10 changes: 10 additions & 0 deletions
10
source/isaaclab_experimental/changelog.d/scene-initialize-renderers.rst
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,10 @@ | ||
| Changed | ||
| ^^^^^^^ | ||
|
|
||
| * Pre-create renderer backends in | ||
| :class:`~isaaclab_experimental.envs.ManagerBasedEnvWarp` and | ||
| :class:`~isaaclab_experimental.envs.DirectRLEnvWarp` by invoking | ||
| :meth:`~isaaclab.scene.InteractiveScene.initialize_renderers` after scene | ||
| construction so that renderer backend creation order is deterministic and | ||
| front-loaded before the first | ||
| :meth:`~isaaclab.sim.SimulationContext.reset`. |
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
9 changes: 9 additions & 0 deletions
9
source/isaaclab_newton/changelog.d/scene-initialize-renderers.rst
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,9 @@ | ||
| Changed | ||
| ^^^^^^^ | ||
|
|
||
| * Split :class:`~isaaclab_newton.renderers.NewtonWarpRenderer` construction | ||
| into a pre-physics ``__init__`` (stores cfg and registers the Newton-Warp | ||
| scene-data requirement on | ||
| :class:`~isaaclab.sim.SimulationContext`) and a post-physics | ||
| :meth:`~isaaclab_newton.renderers.NewtonWarpRenderer.initialize` (reads | ||
| the built Newton model. |
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
20 changes: 20 additions & 0 deletions
20
source/isaaclab_ov/changelog.d/scene-initialize-renderers.rst
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,20 @@ | ||
| Changed | ||
| ^^^^^^^ | ||
|
|
||
| * Construct the underlying OVRTX ``Renderer`` in | ||
| :class:`~isaaclab_ov.renderers.OVRTXRenderer` ``__init__`` instead of | ||
| during :meth:`~isaaclab_ov.renderers.OVRTXRenderer.prepare_stage`. This | ||
| pairs with the new pre-physics ``__init__`` / | ||
| post-physics :meth:`~isaaclab.renderers.base_renderer.BaseRenderer.initialize` | ||
| lifecycle: when invoked eagerly via | ||
| :meth:`~isaaclab.scene.InteractiveScene.initialize_renderers`, the OVRTX | ||
| ``Renderer`` is created before | ||
| :meth:`~isaaclab.sim.SimulationContext.reset` (and therefore before | ||
| ovphysx initialises), which OVRTX 0.3 requires. | ||
| * Replaced an ``assert`` on the OVRTX ``Renderer`` construction with an | ||
| explicit :class:`RuntimeError` so the failure is reported even when | ||
| Python is run with ``-O``. | ||
| * Renamed the internal ``OVRTXRenderer.initialize(spec)`` helper to | ||
| ``_initialize_from_spec(spec)`` to avoid shadowing the new | ||
| no-arg :meth:`~isaaclab.renderers.base_renderer.BaseRenderer.initialize` | ||
| lifecycle hook. |
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 |
|---|---|---|
|
|
@@ -159,6 +159,21 @@ def __init__(self, cfg: OVRTXRendererCfg): | |
| self._camera_rel_path: str | None = None | ||
| self._output_semantic_color_buffer: wp.array | None = None | ||
|
|
||
| logger.info("Creating OVRTX renderer...") | ||
|
Collaborator
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. question: should this live inside the new initialize() method form BaseRenderer? |
||
| OVRTX_CONFIG = RendererConfig( | ||
| log_file_path=self.cfg.log_file_path, | ||
| log_level=self.cfg.log_level, | ||
| read_gpu_transforms=_IS_OVRTX_0_3_0_OR_NEWER, | ||
| keep_system_alive=True, | ||
| ) | ||
| self._renderer = Renderer(OVRTX_CONFIG) | ||
| if not self._renderer: | ||
| raise RuntimeError( | ||
| "Failed to create OVRTX Renderer; the underlying ovrtx.Renderer constructor returned a falsy" | ||
| " value. Check that ovrtx is installed correctly and its native dependencies are available." | ||
| ) | ||
| logger.info("OVRTX renderer created successfully") | ||
|
|
||
| def prepare_stage(self, stage: Any, num_envs: int) -> None: | ||
| """Export the USD stage for OVRTX before create_render_data. | ||
|
|
||
|
|
@@ -178,7 +193,7 @@ def prepare_stage(self, stage: Any, num_envs: int) -> None: | |
| self._exported_usd_path = export_path | ||
| logger.info("Exported to %s", export_path) | ||
|
|
||
| def initialize(self, spec: CameraRenderSpec): | ||
| def _initialize_from_spec(self, spec: CameraRenderSpec): | ||
| """Initialize the OVRTX renderer with internal environment cloning. | ||
|
|
||
| Args: | ||
|
|
@@ -198,17 +213,6 @@ def initialize(self, spec: CameraRenderSpec): | |
| usd_scene_path = self._exported_usd_path | ||
| use_cloning = self.cfg.use_cloning | ||
|
|
||
| logger.info("Creating OVRTX renderer...") | ||
| OVRTX_CONFIG = RendererConfig( | ||
| log_file_path=self.cfg.log_file_path, | ||
| log_level=self.cfg.log_level, | ||
| read_gpu_transforms=_IS_OVRTX_0_3_0_OR_NEWER, | ||
| keep_system_alive=True, | ||
| ) | ||
| self._renderer = Renderer(OVRTX_CONFIG) | ||
| assert self._renderer, "Renderer should be valid after creation" | ||
| logger.info("OVRTX renderer created successfully") | ||
|
|
||
| if usd_scene_path is not None: | ||
| logger.info("Injecting camera definitions...") | ||
|
|
||
|
|
@@ -367,7 +371,7 @@ def create_render_data(self, spec: CameraRenderSpec) -> OVRTXRenderData: | |
| matching the interface of Isaac RTX and Newton Warp which need no separate initialize(). | ||
| """ | ||
| if not self._initialized_scene: | ||
| self.initialize(spec) | ||
| self._initialize_from_spec(spec) | ||
| return OVRTXRenderData(spec, DEVICE) | ||
|
|
||
| # Map torch dtypes to their warp counterparts for zero-copy wrapping. | ||
|
|
||
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.
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.
question: is there a reason not to implement this for all backends?