Repository navigation
[POC] Add Isaac Sim viewer visualizer with a shared OVStage - #8907
matthewtrepte wants to merge 16 commits into
Conversation
Show an Isaac Lab simulation in the Isaac Sim 7 viewer without using Isaac Sim physics or rendering backends. Isaac Lab keeps stepping its own physics (for example Newton MJWarp) and publishes world poses from the scene data provider straight into the viewer's OVStage through DLPack, the same zero-copy path the OVRTX renderer uses. The OVGL renderer then draws the frame. The scene is exported from the authored USD stage into an Isaac Sim 7 simulation context, so every environment is authored with UsdReplicateContext. All dependence on Isaac Sim 7 internals sits in is7_stage.py: adoption of the context's native stage pointer and write-ordinal handling.
Run the Isaac Sim 7 application host in-process with a physics-free world, so the viewer shows the stage tree, properties, content browser and picking while Isaac Lab keeps its own loop and physics. Poses go through the host's command queue.
Port the IS7 visualizer to the split visualizer configuration: backend options live in IS7BackendCfg, while viewport size, host rate and headless come from VisualizerCfg.
Register an Isaac Lab pose engine with the Isaac Sim 7 host. It writes body world matrices and the transform journal at the host's output ordinal before rendering, so the OVGL renderer refreshes only the journaled bodies: 4x the viewer frame rate at 256 cartpole envs and 16x at 1024. The command-queue path stays selectable.
Add stage_mode="shared" (now the default) to the Isaac Sim 7 viewer visualizer, selected with --viz isaac-sim. The host's stage context creates and registers one OVStage; Isaac Lab borrows it, populates the environments through its clone plan, and owns the ordinals: each frame it writes body poses and visualization markers, runs the host's participants through a Python stand-in for the host orchestration, seals, and renders the viewer's products with OVRTX. The host reads the same stage for its stage tree and property panes and streams the frames. Rename the visualizer type to isaac_sim and accept hyphens for underscores in --viz and preset names. Go2 rough terrain, 512 envs, RSL-RL: 12.2k env steps/s with the viewer open, against 6.2k with the Newton visualizer and 19.4k headless.
Match the --viz isaac-sim name in code: isaaclab_visualizers.is7 becomes isaaclab_visualizers.isaac_sim, with IsaacSimBackendCfg and IsaacSimVisualizer and the ISAACLAB_ISAAC_SIM_APP_CLIENT_ROOT environment variable.
[Medium impact] The PR adds an opt-in viewer path that changes how one simulation workflow is displayed and controlled. Fix the no-body rendering failure and the outstanding marker-material failure before merging. Findings
SummaryAdds an experimental Isaac Sim 7 viewer backed by a shared OVStage.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Isaac Lab physics] --> B[Write body poses and markers]
C[Viewer commands] --> D[Apply queued commands]
B --> D
D --> E[Seal shared OVStage]
E --> F[OVRTX renders frames]
F --> G[Host streams frames]
G --> H[Viewer client]
H --> C
Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." · Reviewed by Greptile |
| if material is not None and material_path is not None: | ||
| # File spawners apply a separate material only with Kit; the material itself is plain UsdShade. | ||
| if not material_path.startswith("/"): | ||
| material_path = f"{prim.GetPath()}/{material_path}" | ||
| material.func(material_path, material) |
There was a problem hiding this comment.
Marker materials can stop training
_instancer_usd creates a material again even when the marker spawner already created it. A shape marker with an absolute visual_material_path creates that material inside cfg.func; the second call to material.func then raises ValueError. This escapes the viewer step and stops training.
Only add the fallback material for spawners that skipped it, and check whether the material already exists.
| self._provider = sim.get_scene_data_provider() | ||
| self._paths = list(self._provider.backend.transform_paths) | ||
| self._scales = authored_scales(sim.stage, self._paths) | ||
| started = time.perf_counter() | ||
| replication = None | ||
| if self.backend_cfg.stage_mode == "shared": | ||
| scene, replication = self._export_prototypes(sim) | ||
| else: | ||
| scene = self._export_scene(sim.stage) |
There was a problem hiding this comment.
Environment limits are ignored
IS7Visualizer ignores the environment selection computed by BaseVisualizer. Both export paths include all environments, and pose publication uses every transform_paths entry. Users who set --max_visible_envs or visible_env_indices still see the full scene and pay to render it.
Apply the selection to the viewer stage, or reject these settings until supported.
| def register(view: Any) -> None: | ||
| cloned.result() | ||
| view.write([spec.product], "resolution", np.asarray([spec.resolution], dtype=np.int32)) | ||
| with lock: | ||
| renderer.add_product(spec.product) | ||
| ready.add(spec.product) |
There was a problem hiding this comment.
The queued register callback can undo a later remove_viewport call. Removal drops the product immediately, but the pending callback adds it back without checking whether the viewport is still wanted. That can leave the renderer tracking a removed product.
Keep a desired-product set and check it under the same lock before writing or registering, as the export path already does.
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Design and architecture (1), Scope and over-engineering (2), Implementation (4), Style consistency (2), Test quality (1). Other reviewed categories look good.
- PR description: Replace stale IS7BackendCfg/test_is7_visualizer.py names and the unattached-video placeholder; for throughput/FPS claims, add the command, hardware, warmup, and measured revisions, retaining the stated MJWarp and 512-environment scope.
- Design and architecture: The shared-stage path depends on isaaclab_ov’s private _prepare_scene_copies contract; expose and consume a supported replication API instead.
- Scope and over-engineering: Minimal implementation: extend sim_launcher, presets, scene-data registration, and the visualizer package; keep init, isaac_sim_visualizer_cfg, isaac_sim_visualizer, isaac_sim_shared_stage, isaac_sim_shared_world, isaac_sim_shared_markers, and isaac_sim_external_simulation; merge isaac_sim_stage into the visualizer; delete isaac_sim_world and isaac_sim_poses with export mode, pose transport, and global hyphen normalization. Replace with one smaller PR: shared-OVStage registration and lifecycle, validated at launcher, scene-population, marker-next-frame, and teardown boundaries.
- API: API changes look good.
- Compatibility and deprecation: No breaking changes identified.
- Implementation: SharedStage.close drops its owned UsdContext without closing it, leaking the native context and registered stage; close it after destroying the borrowed stage.
- Style consistency: The new public package hand-rolls lazy exports instead of using lazy_export with an adjacent init.pyi; adopt the required package pattern.
- Test quality: Keep the instance-expansion boundary test, but remove the registration test because it only repeats three newly added literals without exercising dispatch.
Significant concerns. Posted 10 inline findings.
Automated review; human maintainers own approval decisions.
| * ``name`` is itself a real field in ``known_names`` (a user-defined preset | ||
| legitimately reusing the deprecated spelling shadows the alias). | ||
| """ | ||
| if name not in known_names and name.replace("-", "_") in known_names: |
There was a problem hiding this comment.
🟡 Warning · Scope Complexity — Hyphen aliasing added to all presets
This fallback accepts hyphenated spellings for every preset group, and sim_launcher.py:220 duplicates it, solely so --viz isaac-sim resolves. Use the snake_case selector like the other visualizers and drop both hunks.
| __all__ = ["IsaacSimBackendCfg", "IsaacSimVisualizer"] | ||
|
|
||
|
|
||
| def __getattr__(name: str): |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Export module bypasses lazy_export pattern
The contribution guide requires public export modules to call lazy_export() with an adjacent init.pyi declaring all. This hand-rolled getattr duplicates that mechanism and leaves no stub for type checkers.
| ) | ||
| self._pending.add(group_id) | ||
| added = True | ||
| elif group_id in self._pending: |
There was a problem hiding this comment.
🟡 Warning · Implementation — New marker groups skip a write
The pending branch only clears the flag, so a group's state is first written two syncs after creation, not "the next one" as the method docstring promises. Write the group here.
| self._queries.clear() | ||
| self.stage.destroy() | ||
| finally: | ||
| self.context = None |
There was a problem hiding this comment.
🟡 Warning · Implementation — Shared stage context is never closed
close() only drops the reference to the UsdContext created in init, and BorrowedContext.close() deliberately no-ops, so the native context and registered stage outlive teardown. Close it after destroying the borrowed stage.
| class IsaacSimVisualizer(BaseVisualizer): | ||
| """Isaac Sim 7 viewer application driven by Isaac Lab's simulation. | ||
|
|
||
| The Isaac Sim 7 host owns the stage, renderer and UI (stage tree, properties, content browser, picking and |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Class docstring describes non-default mode
This states the host owns the stage and receives poses through its command queue, but the default stage_mode="shared" writes and seals an OVStage here; isaac_sim_visualizer_cfg.py:23 repeats the mismatch.
| super().__init__(cfg) | ||
| self.backend_cfg: IsaacSimBackendCfg = cfg.backend | ||
| if self.backend_cfg.app_client_root is None: | ||
| self.backend_cfg.app_client_root = os.environ.get("ISAACLAB_ISAAC_SIM_APP_CLIENT_ROOT") |
There was a problem hiding this comment.
🟡 Warning · Implementation — Constructor mutates caller-owned backend config
Writing the environment value into cfg.backend mutates a config the preset hands out, so to_dict() and reuse observe a path the user never declared. Store the resolved root on the instance.
| def extra_participants(wake): | ||
| return [NativeParticipant("isaaclab-poses", engine.participant(rate), PHYSICS_POSITION)] | ||
|
|
||
| open_world = make_physics_free_world_opener(specs, rate, renderer="ovgl", extra_participants=extra_participants) |
There was a problem hiding this comment.
🟡 Warning · Implementation — Unused world opener built in shared mode
In the default stage_mode="shared", this opener and renderer_name are overwritten at lines 156 and 165, but constructing it still imports the vendored host module. Select the opener in one branch.
| stage = sim.stage | ||
| plan = sim.get_clone_plan() | ||
| if plan is not None and len(plan.topology.world_prototype_layout) > 1: | ||
| from isaaclab_ov.cloner.replicate import _prepare_scene_copies |
There was a problem hiding this comment.
🟡 Warning · Design Architecture — Depends on private isaaclab_ov cloner helper
_prepare_scene_copies is private to isaaclab_ov.cloner.replicate and is driven through an undocumented SimpleNamespace out-parameter, so refactoring it silently breaks this backend. Expose a public replication entry point instead.
| port: int = 0 | ||
| """Port of the host's HTTP service; zero picks a free one.""" | ||
|
|
||
| stage_mode: Literal["export", "shared"] = "shared" |
There was a problem hiding this comment.
🟡 Warning · Scope Complexity — Export stage mode is parallel subsystem
stage_mode="export" and pose_transport pull in isaac_sim_world.py (288 lines vendored from sim_viewer) and isaac_sim_poses.py, neither used by the shared-stage feature this PR claims. Delete them and the second pose path.
| """ | ||
|
|
||
|
|
||
| def test_isaac_sim_is_registered(): |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Registration test restates added constants
These assertions mirror the VISUALIZER_TYPES, REQUIRES_STAGE_AND_MODEL and visualizer_type literals added in this diff and exercise no dispatch, so they cannot fail for a product reason. Remove the test.
The shared OVStage covers the export mode's use and scales further, so drop stage_mode, pose_transport and deinstance_max_points, the host pose engine and the OVGL world opener. A scene without cloned environments is exported whole through the same path.
Replace the scheduler stand-in with a host adapter: Isaac Lab drains the viewer's command queues each frame, Pause and Step gate its loop, and Stop requests an environment reset. Drop live property inspection, which needs Isaac Sim physics views.
Follow Isaac Sim's viewport_direct example: a Viewer driven from Isaac Lab's thread with no host world or scheduler, serving Isaac Lab's OVRTX frames through a small viewport adapter. Make it the default and keep the application host as host="app". Note the open points for the Isaac Sim team in the module docstring.
Isaac Lab still drives every update; the direct viewer stays available as host="viewer" for a viewport-only window.
Describe cloned prims by their source prim, read-only, since clones exist only in the shared stage. Restore property inspection with live world poses read from the stage; Isaac Sim's own inspection needs native views and Isaac Sim physics.
Serve a copy of the client's shared renderer with its camera bindings changed to match the Newton viewer: left-drag looks, middle-drag orbits, Shift and Ctrl with the middle button pan and dolly. Fall back to the client's own bindings if this client version does not match.
The viewport-only mode lacked the stage, property and content panes and transport controls; the application host, driven by Isaac Lab, is the only mode.
Grant viewer Steps only while paused, reset only on Stop and not when the host reloads authored edits, look cloned prims up by their source first, keep the stock camera controls when the client lacks the expected module, write the transform-stack reset before marking it done, and require the client root before any startup work.
# Conflicts: # source/isaaclab/isaaclab/app/sim_launcher.py # source/isaaclab_tasks/isaaclab_tasks/utils/presets.py
|
run-ci |
|
@greptileai review |
| if not self._provider.get_transforms(self._pose_output, allow_passthrough=True, scales=self._scales): | ||
| return |
There was a problem hiding this comment.
_render_frame returns before calling self._shared.step when the scene has no rigid-body transforms. Empty scenes, static scenes, and particle-only scenes therefore never drain viewer commands or render a frame. Keep stepping the shared stage when no body poses are available; skip only the pose writes.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| open_world=self._shared, | ||
| scene=str(scene), | ||
| viewports=specs, | ||
| viewport_factory=lambda index: dynamic_viewport_spec(index, tuple(self.cfg.window.size)), |
There was a problem hiding this comment.
IsaacSimVisualizer never applies eye, lookat, or focal_length to the viewer cameras. super().initialize skips perspective cameras for this backend, and dynamic_viewport_spec receives only the window size. Existing task camera settings are silently lost, such as Cartpole's eye=(8.0, 0.0, 5.0), so users must reposition the camera themselves. Apply the configured pose and lens when creating each viewport.
Description
Initial proof of concept for using the Isaac Sim 7 viewer application as an Isaac Lab visualizer (
--viz isaac-sim): Isaac Lab keeps its own physics and loop, and Isaac Lab and the viewer share one OVStage as their data layer. This is early, experimental work to evaluate the architecture and performance.isaac_simvisualizer backend (IsaacSimBackendCfg), which runs the Isaac Sim 7 application host in-process and opens its Electron window (viewport, stage tree, properties, content browser, transport controls).ovstage_replicate, then owns its ordinals. Each frame it writes body poses and markers, applies the host's queued commands (camera, viewport, property inspection, edits), seals, and renders the viewer with OVRTX.camera_controls="isaac_sim"keeps the client's Kit-style bindings.Type of change
Screenshots
g1_rough_isaac_sim_viz.mp4
G1 rough terrain, 512 envs, pretrained policy:
G1 rough terrain, 1024 envs, RSL-RL training, Newton MJWarp, 60 iterations (throughput averaged over iterations 5–59), with each viewer window open on a live display:
--viz isaac-sim--viz kit--viz newton* Kit ran in an Isaac Sim 6.1 environment; the other rows ran in the Isaac Sim 7 environment. Both use Isaac Lab's pinned Newton. Repeating the visualizer runs with the display off changed throughput by at most 4%.
Validation
test_isaac_sim_visualizer.pyand launcher/preset tests pass.Limitations
7.0.0a2.dev55385withovstage0.4,ovphysx0.8 andovrtx0.7.dev (Isaac Lab pinsovstage0.3),sim_vieweronPYTHONPATH, and a built viewer client.--viz newtonat 1024 envs (export, stage population, OVRTX setup, application host), and the gap grows with the number of environments.--viz newton).SceneCommands._capture_activation/_published, aWorldsubclass, no-op stand-ins for the host's scheduler calls, and a patched copy of the client's camera bindings.Extensions
AuthoringSessionfrom an in-memory stage, and configurable camera bindings in the client.Checklist
CONTRIBUTORS.md.