Repository navigation
[6Aiii] Use native Newton RTX with a borrowed scene stage - #8303
Conversation
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Scope and over-engineering (1), Compatibility and deprecation (1), Style consistency (2). Other reviewed categories look good.
- PR description: The body covers camera views, lighting, readback, and migration, but should mention Camera.get_world_poses and pose-write invalidation and replace pre-split validation with exact commands run on this head.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: Minimal implementation: extend Camera, BaseVisualizer, and NewtonVisualizer; no source modules were added, and delete select_camera and its branch while retaining source resolution, GL selection/navigation, readback, and light import. Suggested PR breakdown: 1) Camera query/invalidation; 2) GL selection/navigation; 3) OVRTX readback; 4) RTX lighting and default migration, each with focused owner tests.
- API: API changes look good.
- Compatibility and deprecation: Breaking changes: VisualizerCfg.background_color silently changes omitted configurations from blue to backend-native output; preserve the old default, add explicit opt-in, warning, migration guidance, and transition coverage before flipping it.
- Implementation: Implementation looks good.
- Style consistency: The streaming guide contradicts its implemented automatic channel filtering and RGBA fallback; restore the compatibility wording used earlier in the same document.
- Test quality: Test quality looks good.
Significant concerns. Posted 4 inline findings.
Automated review; human maintainers own approval decisions.
| @@ -129,8 +171,7 @@ Then choose what to display in ``VisualizerCfg``: | |||
|
|
|||
| * ``streaming_sensor_prim_path`` selects a scene :class:`~isaaclab.sensors.Camera` by its configured | |||
| prim path. The ``{ENV_REGEX_NS}`` macro uses the scene's environment template. | |||
| If omitted, the first camera supporting the requested channels is selected; without a compatible | |||
| camera the panel stays empty. | |||
| If omitted, the first scene camera is selected; without cameras the panel stays empty. | |||
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Docs contradict implemented channel filtering
_setup_streaming_view now offers only cameras providing every requested channel, as lines 60-65 state. This line and line 188 reinstate the old wording; restore the compatibility and RGBA-acceptance text.
| @@ -113,8 +113,9 @@ def _setup_streaming_view( | |||
| *, | |||
| visible_env_ids: list[int] | None = None, | |||
| target_aspect: float = 1.0, | |||
| select_camera: bool = True, | |||
There was a problem hiding this comment.
🟡 Warning · Scope Complexity — select_camera flag is inert
NewtonGLVisualizer.initialize calls _select_camera immediately after super().initialize, overwriting the base selection, so this flag changes nothing. Delete the parameter, its branch, and the NewtonGLVisualizerCfg isinstance check in NewtonVisualizer.initialize.
| @@ -186,11 +187,11 @@ class VisualizerCfg: | |||
| focal_length: float = 12.0 | |||
| """Camera focal length in millimeters for visualizer camera views.""" | |||
|
|
|||
| background_color: tuple[float, float, float] | None = (0.30, 0.55, 0.82) | |||
| background_color: tuple[float, float, float] | None = None | |||
There was a problem hiding this comment.
🟡 Warning · Compatibility — Background default flips without warned transition
Omitting background_color now changes every existing visualizer's rendered output with no warning. Keep the previous blue default for the deprecation window, add an explicit opt-in for scene backgrounds, and warn before flipping.
| @@ -310,10 +310,12 @@ def _cartpole_integration_visualizer_camera_kwargs( | |||
| return { | |||
| "eye": _CARTPOLE_ALL_ENVS_VISUALIZER_EYE, | |||
| "lookat": _CARTPOLE_ALL_ENVS_VISUALIZER_LOOKAT, | |||
| "background_color": (0.3, 0.55, 0.82), | |||
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Golden background literal repeated four times
This RGB tuple is repeated four times, twice appended after the dict literal rather than inside it. Define one named module constant beside _CARTPOLE_INTEGRATION_VISUALIZER_EYE and reuse it.
|
| composite = self._streaming_frame.data | ||
| if composite is None or not self._viewer.is_paused(): | ||
| composite = self.render_tiled_rgb_array() |
There was a problem hiding this comment.
Paused camera switch shows old image When a user selects another scene camera while rendering is paused, the selection invalidates the image timestamp but leaves the previous pixels cached. This paused path displays those pixels without reading the newly selected camera, so the dropdown can name one camera while the viewport continues showing another indefinitely.
| camera = self._camera_sensor | ||
| navigating = self._viewer is not None and not self._runtime_headless and camera is not None | ||
| before = self._viewer.camera.get_view_matrix().reshape(4, 4).T if navigating else None | ||
| super().step(dt) | ||
| if not navigating or self._viewer is None or self._viewer.is_paused() or camera is not self._camera_sensor: |
There was a problem hiding this comment.
Camera navigation trails the image
super().step(dt) captures and displays the selected camera’s image before this method applies the navigation change to the sensor. During navigation, each displayed frame therefore shows the previous sensor pose; the updated view appears only on a later rendered frame, making the controls feel delayed.
# Description Visualizers borrow scene-declared cameras instead of creating their own sensors. The scene owns capture and lifetime; each viewer selects existing outputs and environment tiles. `SceneCameraCfg` references a sensor, while `PerspectiveCameraCfg` configures an interactive view. This is **6Ai**, the shared camera and image-composition foundation. The stack continues with shared OVRTX products in **6Aii (#8319)** and interactive GL/RTX camera views in **6Aiii (#8303)**. Visualizer launch selection remains in #8126. Visualizers prepare environment indices, grid dimensions, and depth colors directly when the view or source layout changes. `isaaclab.utils.images.compose_image()` consumes explicit arrays and display settings, and channel-specialized Warp kernels write RGB, depth, normals, and segmentation into reusable device RGBA storage. A single shared kernel body generates four variants using static branches; the display mode is not a kernel argument. The GPU compositor and its kernel live in the existing image utilities; shared display-layout calculations stay in `camera_view.py`. Kit consumes that device image directly. `render_tiled_rgb_array()` is the explicit readback boundary for recording and web clients. SimulationContext resolves camera references once and supplies the bound cameras and authored stage. Visualizers do not receive ClonePlan or rediscover scene cameras. Initial perspective poses use the configured eye and look-at fields directly. BaseVisualizer selects visible environments once; viewers, markers, and camera tiles consume that final selection. Unused generated-camera setup and redundant pose and environment-selection helpers have been removed. **Migration:** Declare cameras with scene `CameraCfg` objects. Replace generated `streaming_cam_*` and deprecated `tiled_cam_*` settings with `cameras`, `streaming_view`, and `streaming_envs`. Custom visualizers must forward the required `cameras` list and optional `stage` during initialization and call `super().close()` after native teardown. Use `get_visualized_env_ids()` after initialization instead of the removed `newton_adapter.resolve_visible_env_indices` and `apply_viewer_visible_worlds` helpers. ## Validation - Channel specialization: 121 focused tests passed across composition, image utilities, scene-data transforms, and visualizer initialization. Extended the existing mixed-channel test; it rejects the old runtime-switched kernel. Camera-first and simulation-first imports and sensor filtering passed in fresh processes. - GPU 0 specialization benchmark (RTX 5090, 16 × 640×480 tiles, 30 alternating paired iterations after warmup): synchronized RGB composition 0.0524 → 0.0505 ms, mixed RGB/depth/normals/segmentation 0.2548 → 0.2504 ms. Other channels were essentially unchanged. Pixel-identical output for all channels; capture, presentation, and encoding excluded. Generated RGB code has no depth/segmentation branch. - 145 focused tests passed for initialization, environment selection, GPU composition, markers, Kit scene partitions, Newton adapters, and web viewers. Selection tests were consolidated at the base initialization contract and failed against the old implementation. A negative mutation confirmed the ownership test rejects restoring a second visibility cache. - Existing tests cover reused output storage, invalid channel layouts, and channel/depth-range changes. The ownership test rejects reinstating a composition parameter wrapper. - A paired GPU 0 composition check measured 0.0524 ms before inlining and 0.0522 ms after, with pixel-identical RGBA output (16 × 640×480 tiles, 30 synchronized iterations after warmup; capture and presentation excluded). - The lifecycle regression fails if ClonePlan is passed to visualizer initialization. - The real Kit/PhysX tiled-camera integration test passed on GPU 0. - Composition benchmark on an RTX 5090: 16 × 640×480 tiles, 30 synchronized iterations after warmup; CPU 28.740 ms, new Warp RGBA 0.0535 ms, existing Torch RGB 0.0367 ms. RGB pixels matched exactly. Capture, presentation, and encoding are excluded; this is not an end-to-end FPS claim. - Formatting, lint, changelog validation, and a clean documentation build passed. ## Type of change - New feature - Breaking change - Bug fix - Documentation update ## Release backport - [ ] <!-- backport-active-release --> Backport this pull request to the active release branch after it merges into `develop` ## Checklist - [x] Read the contribution guidelines - [x] Ran formatting/lint and changelog checks - [x] Updated documentation and migration guidance - [x] Validated focused coverage and retained existing test owners - [x] Added package changelog fragments - [x] Contributor already listed - [x] Clean local documentation build --------- Co-authored-by: Maximilian Krause <[email protected]>
3c9c060 to
1369a8b
Compare
e7180b1 to
3c82f2d
Compare
|
run-ci |
1369a8b to
3f8e94d
Compare
|
run-ci |
3f8e94d to
3f8fb01
Compare
|
run-ci |
|
run-ci |
StafaH
left a comment
There was a problem hiding this comment.
Leaving some initial comments, please cleanup and then will further review.
| - Preserve unrelated workspace changes and do not commit generated plans, scratch files, or agent artifacts. | ||
| - Use the repository's current SPDX header template for new source files; do not change existing file headers. | ||
| - Follow the existing style and abstractions in the affected package. | ||
| - Keep visualizer backend construction and rebinding in its implementation. Core initialization and |
There was a problem hiding this comment.
Please remove changes to agents.md. Such implementation details should be in the code itself as comments for both agents and users
| Display layout and channel mappings are compiled when the source, selection, resolution, or | ||
| color settings change. Composition writes into reusable device RGBA storage. Newton GL, Newton | ||
| RTX, and Kit present CUDA images without downloading pixels. Recording through | ||
| ``render_tiled_rgb_array()`` and the Rerun/Viser transports explicitly read back the composed |
There was a problem hiding this comment.
these two functions are named so similar, but one has array and one does not, thats odd
| """Camera focal length in millimeters for visualizer camera views.""" | ||
|
|
||
| background_color: tuple[float, float, float] | None = (0.30, 0.55, 0.82) | ||
| background_color: tuple[float, float, float] | None = None |
There was a problem hiding this comment.
Is this because the cameras already have background config. If so why do we even need background color for visualizers?
| @configclass | ||
| class NewtonVisualizerCfg(VisualizerCfg): | ||
| """Shared configuration base for Newton visualizer backends. | ||
| class _NewtonWindowCfg(VisualizerCfg): |
There was a problem hiding this comment.
Since none of these options have to do with Newton, why not just make a generic WindowCfg? (also let's avoid _ class names)
| """Run the Newton viewer without requiring a display server.""" | ||
|
|
||
| update_frequency: int = 1 | ||
| """Visualizer update frequency (renders every N simulation frames).""" |
There was a problem hiding this comment.
Visualizers should probably just use a fixed desired update frequenchy, e.g. 30fps, rather than doing some skip logic from the simulation frames
| show_particles=True, | ||
| particle_color=tuple(self.scene.media.spawn.visual_color), | ||
| ) | ||
| self.sim.default_visualizer_cfg = NewtonRTXVisualizerCfg(eye=(0.9, 0.65, 0.5), lookat=(0.5, 0.0, 0.1)) |
There was a problem hiding this comment.
maybe it's time to change default_visualizer_cfg -> visualizer_cfg? Is there some non-default visuzaliser config
| @@ -1054,11 +1054,6 @@ def play_mode(self) -> None: | |||
| self.reset_cycle = True | |||
| self.reset_level_probabilities = (0.0,) * (len(self.reset_randomization_scales) - 1) + (1.0,) | |||
| camera_cfg = self.sim.default_visualizer_cfg | |||
There was a problem hiding this comment.
something weird is happening here and below, you are grabbing camera_cfg from sim.default_visualizer_cfg and then immediately replacing that value with NewtonRTXVisualizerCfg using the camera_cfg values in the argument. Why is there a camera cfg inside self.sim.default_visualizer_cfg
| self._streaming_layout = self._streaming_view_key = None | ||
| self._streaming_keys = () | ||
| self._scene_data_provider = self._scene_stage = None | ||
| self._scene_data_provider = self._sim = None |
There was a problem hiding this comment.
? we are storing self._sim already, why also double save it under self._scene_data_provider?
|
run-ci |
|
run-ci |
|
run-ci |
|
run-ci |
StafaH
left a comment
There was a problem hiding this comment.
Reviewed PR #8303 at 4a7ee01. Not ready to merge: borrowed-stage geometry updates are incomplete and native model rebinding can infer a false coordinate offset after hard reset. Additional findings cover sensor-only resource construction, mutable window defaults, GL input ordering, and a broken media helper. The PR's acknowledged two-renderer startup stall also remains a merge prerequisite.
| self._log_streaming_image() | ||
| else: | ||
| if not viewer.is_paused(): | ||
| viewer.log_state(self._update_state()) |
There was a problem hiding this comment.
Major: Publish deformable and particle geometry to the borrowed stage
This path sends state to ViewerRTX, but its borrowed-stage mode only binds rigid-body transforms by body_label. OvstageBackend.populate exports points once, and neither owner subsequently writes the SDP geometry arrays to those prims. The pinned viewer also defaults show_particles/show_triangles to false in this mode. Consequently authored MPM particle clouds and deformable meshes remain at their initial geometry even while particle_q changes; removing show_particles from the task configs does not replace that update path. Reuse the geometry binding/write operation in OVRTXRenderer.update_geometries: bind paths once, publish the provider's device arrays when geometry_timestamp changes, and order the writes before the viewer advances the stage floor. Keep this as shared stage-data code rather than a second geometry traversal in the visualizer.
| def reset(self, soft: bool = False) -> None: | ||
| """Restore RTX camera selection after Newton replaces its camera during model binding.""" | ||
| previous = self.backend | ||
| super().reset(soft) |
There was a problem hiding this comment.
Major: Restore stage poses before rebinding a fresh model on hard reset
super().reset() calls ViewerRTX.set_model() while the borrowed stage still contains the previous rollout's poses. The pinned Newton implementation infers its model-to-stage transform from those stage poses and the new model's initial body_q. I reproduced this with native OVStage/Newton bindings: moving /Body to x=3 then rebinding a model initialized at x=0 produces _stage_from_model=(3,0,0,0,0,0,1). It treats simulated motion as a coordinate-system offset, so subsequent poses and debug geometry are shifted after reset. Restore the stage to the new model's reference poses before binding, or preserve an explicit stable model-to-stage mapping that is not re-inferred from animated data. Extend the RTX reset check to assert spatial alignment after root-body motion, not just image shape.
| super().initialize(sim, cameras=cameras) | ||
| scene_data_provider = self._sim.get_scene_data_provider() | ||
| scene = self._sim.get_or_create_backend(OvstageBackendCfg(viewer_id=id(self))) | ||
| scene.populate(self._sim.stage, sim.get_clone_plan()) |
There was a problem hiding this comment.
Minor: Do not construct a perspective scene for sensor-only presentation
Even cameras=[SceneCameraCfg(...)] unconditionally builds/binds the Newton model and exports/clones a separate OVStage before displaying the already-rendered sensor output. The native Viewer's first interactive end_frame also initializes OVRTX before checking fullscreen image presentation. A Warp-camera-only window therefore acquires an unnecessary RTX scene/renderer and its startup and memory costs; with an OVRTX sensor it also enters the already-reported two-renderer startup path. Separate image presentation from perspective-scene construction, and lazily acquire the latter only when a PerspectiveCameraCfg is selected. Keep resolved sensor arrays and window presentation usable without constructing another scene.
| cloning_contexts: tuple[type | str, ...] = () | ||
| """Clone contexts that build this visualizer's scene representation from the asset plan.""" | ||
|
|
||
| window: WindowCfg = WindowCfg() |
There was a problem hiding this comment.
Minor: Merge nested window defaults by field and copy their values
The new mutable WindowCfg is still handled by SimulationContext._apply_default_visualizer_cfg's shallow whole-field assignment. With a task default WindowCfg(size=(640,480), fps=60), GL and RTX configs at their defaults receive the exact same WindowCfg object. Changing the GL FPS slider changes RTX and the task template too. Conversely, specifying only WindowCfg(fps=20) prevents the task's size from being inherited, yielding 1920x1080 instead of 640x480. Both cases reproduce on this head. Merge size/fps using the existing per-field default semantics and give each resolved visualizer its own WindowCfg; extend the existing default-propagation test.
| viewer = self._viewer | ||
| viewer.begin_frame(self._sim_time) | ||
| try: | ||
| self._navigate_scene_camera() |
There was a problem hiding this comment.
Minor: Process GL input before reading and composing the sensor frame
The existing camera-navigation latency comment remains applicable to GL. Unlike ViewerRTX.begin_frame, the pinned ViewerGL.begin_frame does not poll input or integrate camera movement: ViewerGL.end_frame calls _update(), which does renderer.update() and _update_camera(dt). This code reads the old view matrix and uploads the sensor image before those operations, so the image presented in that frame trails the new input by one window update (about 33 ms at the default cap). The navigation test injects the final view matrix before step(), so it cannot detect the ordering problem. Provide a pre-render input/update phase or callback, then apply the camera delta, acquire the sensor image, and present; avoid pumping/integrating input twice.
| lookat=(0.0, 0.0, 0.0), | ||
| focal_length=_HERO_NARROW_FOCAL_LENGTH, | ||
| rtx_environment="studio", | ||
| sky_upper_color=_HERO_SKY_UPPER_COLOR, |
There was a problem hiding this comment.
Minor: Remove the remaining RTX-only caller's deleted sky arguments
_hero_make_newton_rtx_visualizer_cfg still passes sky_upper_color and sky_lower_color. NewtonRTXVisualizerCfg now inherits directly from VisualizerCfg, so those GL fields are no longer accepted. Constructing this config raises TypeError: unexpected keyword argument 'sky_upper_color', preventing the RTX hero capture from starting. Remove both arguments and configure the intended background/lighting through the supported scene or background_color path; the adjacent comments about unsupported streaming and markers also need updating.
| num_cloned_sources += 1 | ||
|
|
||
| logger.info("Cloned %d sources successfully in OVRTX", num_cloned_sources) | ||
| if self._use_ovstage: |
There was a problem hiding this comment.
nit: Move legacy environment-path allocation below the OVStage return
num_envs/env_paths are built before this branch, but ovstage_replicate builds its own environment paths and returns. The default OVStage path therefore formats and allocates an unused O(num_envs) list. Move the two legacy-only assignments below the early return; this preserves behavior and removes duplicate setup work.
| norm_translations, norm_orientations, norm_scales, norm_marker_indices, norm_environment_ids | ||
| values = (norm_translations, norm_orientations, norm_scales, norm_marker_indices, norm_environment_ids) | ||
| target_device = self._device or next( | ||
| (value.device for value in values if value is not None), torch.device("cpu") |
There was a problem hiding this comment.
need to be careful about device resolution. This should be driven from our env cfg, in a previous PR this was addressed for other parts of code, this should apply here as well.
| @@ -217,12 +220,12 @@ def visualize( | |||
| norm_scales = self._to_tensor(scales, expected_width=3, name="scales") | |||
| norm_marker_indices = self._to_index_tensor(marker_indices, name="marker_indices") | |||
There was a problem hiding this comment.
I know this isn't part of PR, but whats happening here with these values, it looks so suspicious. Is this some conversion? Should everything be ProxyArray, or strictly typed to specific type (torch.Tensor)?
| if not any(isinstance(backend, NewtonVisualizationMarkers) for backend in self._backends): | ||
| self._backends.append(NewtonVisualizationMarkers(self.cfg, visible=self._is_visible)) | ||
|
|
||
| def _resolve_target_device(self, *values: torch.Tensor | None) -> torch.device: |
There was a problem hiding this comment.
Same as above comment, removing this is good, but we shuold have device resolution happen 1 place globally and pass that value in
| self._scene_data_provider = scene_data_provider | ||
| self._scene_stage = stage | ||
| self._sim = sim | ||
| self._camera_choices = list(cameras) |
There was a problem hiding this comment.
self._camera_choices -> self._cameras
|
run-ci |
|
run-ci |
|
run-ci |
|
run-ci |
Description
Newton RTX now uses native
ViewerRTX(ovstage=...)with a simulation-owned scene stage instead of rebuilding viewer USD from the Newton model. Authored lighting, materials, and clone placements reach the viewer directly; Newton retains its window, perspective camera, and debug markers. OVStage and OVRTX share private copy batching that omits children already supplied by their parent.GL and RTX share camera selection and model-reset code. Contact rendering uses the sensor interface directly; selected PhysX environments retain the correct body-pose ordering. Marker inputs normalize directly to the simulation device, including host arrays and partial prototype-index updates. Window defaults merge per field without sharing mutable state. Newton and Kit use shared
WindowCfg(size=...); Newton windows use a wall-clockfpslimit (30 by default) instead of skipping simulation frames. Scene-camera images stay on the GPU for display, and window resizing scales fixed-resolution images without resizing sensors. Backend construction stays inside the visualizer, using the simulation owner passed toinitialize(sim, cameras=...).This is PR6Aiii. Shared
ImageViewCfg, window/recorder frame caching, and removal of duplicate CPU composition are split into PR6Aiv (#8432). Follows merged #8103, #8319, and #8381; incorporates #8221 without #8232.Migration: Use Camera View instead of Open/Hide. Remove RTX
rtx_environment,world_spacing, and GL model options; author lights and placement in the scene. Use GL for dragging and model overlays. Custom visualizers must adoptinitialize(sim, cameras=...). Movewindow_width/window_heighttowindow=WindowCfg(size=(width, height)), replace Newtonupdate_frequencywithwindow.fps, and userender_tiled_rgba_array()for GPU images. Runtime material randomization is not yet propagated to the borrowed stage.Validation
The review cleanup passed 121 tests on GPU0, including the full marker suite and native RTX motion/pause/marker integration; the two lighting cases below remain skipped. The extended existing tests reproduced the window aliasing, partial-default inheritance, and marker-device bugs before their fixes. The RTX media configuration now constructs successfully. Formatting/lint and changelog checks passed; full CI is being rerun.
Startup to the first rendered image, in seconds: baseline → combined implementation, measured at preserved revision
00adda3a9againsta3acc244dbefore this split. These measurements include the shared-view follow-up and are not a new measurement of the isolated PR6Aiii branch. Every case includes the Newton RTX viewer at 640×480; RGB adds one 64×64 OVRTX sensor per environment. Timings include process launch, physics, scene, and viewer setup.Single runs with warmed caches and identical dependencies on an RTX 5090, GPU0 only. All 16 PR cases passed image validation and three rollout steps. Four 4,096-environment Kuka baselines exceeded available host RAM; these have no valid timing and need a repeat after memory is freed. The other 12 baselines passed. Benchmark setup.
Temporary test skip and follow-up
The two lighting/lifetime cases using an OVRTX sensor are temporarily skipped because the sensor and native viewer create separate OVRTX renderers; the second can stall when the first has loaded a scene but never rendered. The two Warp-sensor cases remain enabled and passed on GPU0 (2 passed, 2 skipped in 18 seconds). This skips affected coverage; it does not fix the runtime stall.
Re-enable those cases after Newton #4627 merges and Isaac Lab adopts its shared-renderer API. The test body and its ownership, lighting, and sensor-buffer assertions remain intact.
The shared-renderer integration will also address stale deformable geometry, pose-offset inference on hard reset, and unnecessary perspective-scene construction for sensor-only windows. These are confirmed limitations of the current separate-stage path, not fixed by this cleanup.
GL sensor navigation still reads input one frame late. Fixing that requires an input-update phase before image composition in Newton; the current code does not add a second input pump.
Type of change
Release backport
developChecklist