Repository navigation
Add viewer gaze and foveation controls for foveated cameras - #9182
Conversation
Every foveated camera adds a collapsing section to the Newton viewer's side panel with gaze tilt and pan sliders that follow the camera's gaze, a center button, and a discrete log-spaced cmf_a selector (viewer_gaze_controls, viewer_cmf_a_values). Newton cameras with a fixed sample count change cmf_a at runtime through FoveatedCamera.set_cmf_a; other renderers show it as fixed. The foveated camera example puts the eye in the viewer's scene-camera slot, covers the view with the sphere and retina comparison, and steers the gaze by dragging or with I/J/K/L. The comparison redraws only when the viewer shows a new eye frame and reuses that frame, so OVRTX sampling noise no longer makes it flicker in a still scene.
[Medium impact] The PR appears safe to merge; both previous findings are fixed and no new actionable issues were found. SummaryAdds viewer controls for foveated cameras and runtime foveation changes on supported Newton cameras.
Reviews (2) · Last reviewed commit: "Address review of the viewer gaze and fo..." · Reviewed by Greptile |
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Design and architecture (1), Scope and over-engineering (1), Compatibility and deprecation (1), Implementation (5), Style consistency (5), Test quality (3). Other reviewed categories look good.
- PR description: Title matches scope; disclose O/U removal, replace “switching back is free” with “avoids retina construction,” and benchmark image-equality viewer latency using revisions, workload, hardware, backend, environment count, warmup, and baseline/head timings.
- Design and architecture: Collected cameras leave viewer callbacks retaining controls and gaze buffers; detach those callbacks when the camera is collected or closed.
- Scope and over-engineering: Minimal implementation: Extend FoveatedCamera’s sampling owner and FoveatedNewtonCamera’s ray-storage owner; keep gaze_controls.py for its registration lifecycle and the example for steering and composition; delete per-switch full-ray temporaries in favor of cached padded directions and direct direction-view updates. Scope is cohesive; no split recommended.
- API: API changes look good.
- Compatibility and deprecation: Breaking changes: documented O/U retina magnification is removed without functional bindings, targeted warnings, migration guidance, or transition coverage; retain it through a deprecation cycle.
- Implementation: Repeated slider and button labels share ImGui IDs across cameras, mixing interaction state; scope each camera’s child widgets with a unique ID.
- Style consistency: New backend capability class variables lack the required ClassVar annotations; annotate both declarations as ClassVar[bool].
- Test quality: The registration test bypasses camera construction and cannot detect removal of automatic wiring; construct the camera, reset the simulation, and observe attachment and cleanup.
Significant concerns. Posted 16 inline findings.
Automated review; human maintainers own approval decisions.
|
@matthewtrepte this picks up your idea on #9074 to put the controls in the Newton viewer's side panel. Every |
Give each camera's side-panel widgets their own ImGui ID scope, so two cameras' sliders no longer share state, and keep the camera's starting cmf_a as a foveation option after a switch. Release the controls' buffers when the camera is collected. Clear the cmf_a retina cache when the camera initializes again, cache the renderer's rays per value instead of rebuilding them on each switch, and annotate the backend capability flags as ClassVar. In the example, redraw the comparison when the gaze or foveation changes as well as when the eye frame does, and cover the view once the window exists and again only when the view is resized, so a moved window stays. Test the RTX refusal without a simulator, run the runtime cmf_a render case on Newton only, check that building a camera adds its controls, and check that the sliders follow a gaze set elsewhere.
|
@isaaclab-review-bot review |
|
@greptileai review |
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Scope and over-engineering (1), Compatibility and deprecation (1), Implementation (3), Style consistency (4), Test quality (1). Other reviewed categories look good.
- PR description: Correct reset-registration and pixel-for-pixel claims; benchmark per-loop device polling and retina-cache memory using reproducible baseline/candidate revisions, commands, hardware, backend, environment count, warmup, latency, and memory metrics.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: Minimal implementation: extend FoveatedCamera for CMF state and registration, FoveatedNewtonCamera for ray writes, and the existing example for steering and comparison; keep the sole added module, gaze_controls.py, for callback lifecycle, but delete duplicate gaze scratch buffers in the controls and example by using camera-owned writable storage. Scope is cohesive; no split recommended.
- API: API changes look good.
- Compatibility and deprecation: Breaking changes: documented O/U comparison zoom is removed without a deprecation bridge; retain functional keys during a warned, documented transition with coverage.
- Implementation: Shared-camera edits invalidate only the originating window, leaving other attached camera views stale while paused; invalidate every affected view.
- Style consistency: Incomplete annotations obscure the steering callbacks and five-field retina cache; specify concrete parameter, return, and cache-record types.
- Test quality: Registration coverage calls the helper directly or inventories private callbacks rather than observing automatic controls; consolidate it into a constructed-camera reset test that observes the registered UI.
Significant concerns. Posted 10 inline findings.
Automated review; human maintainers own approval decisions.
| imgui.set_tooltip("Smaller cmf_a concentrates the samples at the fixation; larger spreads them evenly.") | ||
| if changed and values[index] != current: | ||
| camera.set_cmf_a(values[index]) | ||
| view = getattr(visualizer, "current_image_view", None) |
There was a problem hiding this comment.
🔴 Critical · Implementation — Invalidate every affected window
Both control paths change a shared camera but invalidate only the originating window. Other Newton windows can retain stale images while paused; invalidate every attached view displaying that camera.
There was a problem hiding this comment.
Fixed in 03b0d28: the controls keep the windows they are attached to, and a slider, button or foveation change redraws the camera view of every one. The slider test attaches a second window and checks both redraw.
| viewer = viewers[0] | ||
| tilt = int(viewer.is_key_down("i")) - int(viewer.is_key_down("k")) | ||
| pan = int(viewer.is_key_down("j")) - int(viewer.is_key_down("l")) | ||
| magnify = int(viewer.is_key_down("o")) - int(viewer.is_key_down("u")) |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Retain documented O/U zoom
Removing O/U drops documented comparison magnification, which changing foveation does not replace on fixed RTX cameras. Keep the keys functional during a warned, documented deprecation transition and validate both interactions.
There was a problem hiding this comment.
Leaving this as is, for the reasons in the earlier thread, plus one more: the O/U keys arrived with #9074, merged a few hours before this PR and in no release, so there is no user to carry through a deprecation. The PR description states the removal.
| return cover | ||
|
|
||
|
|
||
| class GazeSteering: |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Keep functions before classes
GazeSteering now precedes main, contrary to the prescribed order of public functions before public classes. Move main above the class; its invocation remains after the definition.
There was a problem hiding this comment.
Moved main above GazeSteering in 03b0d28.
| DRAG_DEG_PER_PIXEL = 0.15 | ||
| GAZE_LIMIT_DEG = 85.0 | ||
|
|
||
| def __init__(self, camera: FoveatedCamera, visualizers: list): |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Complete steering callback annotations
The new constructor uses a bare list, and its constructor and mouse callbacks omit return annotations. Specify the visualizer element and callback argument and return types.
| from pyglet import event | ||
|
|
||
| self.press_over_panel = imgui.get_io().want_capture_mouse | ||
| if self.press_over_panel and comparison_image_hovered(imgui): |
There was a problem hiding this comment.
🟡 Warning · Implementation — Intercept only left presses
The handler consumes every press over the comparison image, although only left drags steer gaze. Right and middle presses lose normal handling; check the button before returning EVENT_HANDLED.
There was a problem hiding this comment.
Fixed in 03b0d28: the press handler returns at once for any button but the left one, so right and middle presses keep their usual handling.
| # or foveation changes; re-rendering in between would show OVRTX's frame-to-frame sampling noise as | ||
| # jitter. | ||
| latest = viewers[0].current_image_view.frame.data | ||
| state = (tuple(camera.gaze_angles.torch[0].tolist()), camera.cfg.cmf_a_deg) |
There was a problem hiding this comment.
🟡 Warning · Implementation — Avoid per-loop GPU synchronization
Reading gaze with tolist() and comparing the full frame with torch.equal synchronizes and scans device data every loop, including unchanged views. Use change signals instead of device-content polling.
There was a problem hiding this comment.
Leaving this as is. The viewer's image view exposes no frame counter to watch instead, the example's loop already waits on each render, and comparing one small image per loop does not show next to rendering. It is an example, so I'd rather not add plumbing to the viewer for it.
| """Axis signs between OpenGL camera-frame directions (x right, y up, -z forward) and ROS ones (x right, y down).""" | ||
|
|
||
|
|
||
| def fixed_count_style(style: str) -> bool: |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Mark internal predicates private
fixed_count_style and runtime_cmf_a_limitation serve only camera and panel internals, but their names advertise a public module API. Prefix both with underscores and update their callers.
There was a problem hiding this comment.
Renamed to _fixed_count_style and _runtime_cmf_a_limitation in 03b0d28.
| self._segmentation_neighbors: torch.Tensor | None = None | ||
| self._sensor_fov_valid: torch.Tensor | None = None | ||
| self._pooler = None | ||
| self._retinas: dict[float, tuple] = {} |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Type the retina cache record
dict[float, tuple] erases the five-field record unpacked by set_cmf_a. Annotate its coordinate, ray, renderer-ray, and pooler fields so changes to the cache remain checkable.
There was a problem hiding this comment.
Fixed in 03b0d28: the cache holds _Retina named tuples with typed fields.
| def _set_gaze(self, camera: FoveatedCamera, angles: tuple[float, float], visualizer: BaseVisualizer) -> None: | ||
| """Set ``angles`` [deg] in every environment and redraw the window's camera view, even while paused.""" | ||
| gaze = camera.gaze_angles.torch | ||
| if self._angles is None or self._angles.shape != gaze.shape: |
There was a problem hiding this comment.
🟡 Warning · Scope Complexity — Reuse camera-owned gaze storage
The controls and GazeSteering allocate separate angle buffers despite gaze_angles documenting writable storage. Update that buffer in place and pass it to set_gaze_angles; remove the duplicate buffers and copies.
There was a problem hiding this comment.
Done in 03b0d28: the controls and the example's steering write into the camera's gaze_angles and pass that buffer to set_gaze_angles, as the gaze action does, so neither keeps its own copy.
|
|
||
| def test_every_foveated_camera_adds_its_sliders_on_reset_until_it_is_gone() -> None: | ||
| camera = _SliderCamera(num_envs=1) | ||
| before = set(SimulationContext._reset_callbacks) |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Prove automatic registration at camera boundary
This stand-in calls the helper directly, while the render case inventories private callbacks; neither proves camera construction displays controls. Consolidate them into a constructed-camera reset test observing the registered UI.
There was a problem hiding this comment.
Leaving this split as is. Observing the drawn UI from a constructed camera needs a Newton viewer window in the test, which CI does not have. Together the two cases cover the chain: building a camera in a scene registers its controls (Newton render case), and the registered callback attaches to Newton windows and draws there (simulator-free case).
Redraw the camera view of every window the controls are in, not only the one that changed. Write slider and steering changes into the camera's own gaze buffer instead of separate copies, and let the example's comparison window keep right and middle presses. Give the retina cache a typed record, mark the runtime cmf_a helpers private, put the example's main before its steering class, and annotate the steering callbacks.
|
run-ci |
|
@kellyguo11 @matthewtrepte this is ready for review. Greptile has no open findings, and both rounds from the Isaac Lab review bot are addressed in d569921 and 03b0d28, with replies on each thread. Points left for you to weigh, where I pushed back:
|
With renderer=isaacsim_rtx the example crashed while Kit started: its top-level imports loaded the pip USD library before launch_simulation started Kit, whose own USD then failed to load. The example now imports pxr inside the clutter helper, which runs after launch, and imports the FoveatedCamera and BaseVisualizer runtime classes, which load USD, only for type checking, as the microduck-warehouse demo keeps runtime imports out of module scope.
Binocular gaze now stacks on isaac-sim#9182 as well as isaac-sim#9181. Both added to FoveatedCamera and the render cases at the same places; the merge keeps both: gaze_writes beside _renders_switchable_rays, mount_pos_w and update_mount beside supports_runtime_cmf_a, and the hybrid and binocular cases before the runtime cmf_a case.
The example crashed on main with renderer=isaacsim_rtx; a119576 fixed it without a changelog entry. The entry goes in isaaclab's changelog, where the example was added.
…ig keys FoveatedCameraCfg carried two viewer settings: viewer_gaze_controls, which only kept the example's helper overview camera out of the side panel, and viewer_cmf_a_values, the foveation slider's stops. Both are gone. A Newton window now draws a camera's controls while its camera view shows that camera, so a camera the viewer cannot show, such as the overview, has none, and switching cameras in the window's menu switches the controls. The stops are ViewerGazeControls.cmf_a_values, now 0.001 to 1000 degrees in decades, which the sliders read as they draw, with each camera's starting cmf_a added. ViewerGazeControls is exported and documented for that. The foveated-camera example sets the stops with --cmf_a_values, comma separated so that the overrides after it stay overrides.
|
@nblauch if you have time, do you mind sharing a quick video or screenshot of what the controls look like? |
|
are the foveated viewer controls specific to this example script? ideally, the way it would work, is if the user in the newton visualizer, selects a foveated camera as their source camera, than these foveated controls get exposed. i think can they live next to the "focal length" slider. |
Screencast.from.2026-11-24.13-55-55.webm |
They're not specific to the example: every The placement is the one difference. From outside the visualizer, a sensor can only add controls through The video is in the comment above. |
The Newton visualizer let other code add controls only through its register_ui_callback slots, so the foveated camera's gaze and foveation controls sat in their own section under the Simulation header. NewtonVisualizerBase.register_sensor_ui_callback adds a generic hook: while a scene sensor is a window's camera source, each callback draws in the Camera Sensor section, after its channel and environment controls, with that sensor. The environment controls move to _draw_sensor_envs so that their early return for a single-environment sensor does not skip the callbacks. Foveated cameras register through it and draw a "Foveated Camera" group when the sensor is theirs.
The comparison window's header titled its two images "Viewing sphere" and "Retina" and showed the CMF constant, which the foveation slider below the Camera Source selector already shows; the right image is also the cortical view rather than the retina. The window now shows the two images side by side, and the example no longer needs PIL or NumPy.
…and example The docs page and the foveated-camera example still placed the gaze and foveation sliders in the side panel at large and called the camera's image the retina. The Sampling section now names the published lattice image the retina's cortical view, and the example's description, help text and docstrings use that name and place the sliders below the Camera Source selector, in the Camera Sensor section.
The cortical view belongs to the foveated camera, not to its retina; the docs page and the foveated-camera example now say so.
|
Both nits are addressed:
f8ae4e5 and 656523b update the docs page and the example's description to match. |
The comparison composes the foveated camera's output image, which is in cortical space; the retina is the sampling space it comes from.
|
run-ci |
Description
Follows #9074, which added
isaaclab_foviand thefoveated-cameraexample. This adds the viewer controls suggested in its review, so a foveated camera can be steered and its foveation changed while watching it. It also fixes the example's crash on Isaac RTX, a bug onmain.Viewer controls (
isaaclab_fovi.sensors,isaaclab_visualizers)FoveatedCameraCfgconfigures them. Each camera registers its controls when it is built, they reach every Newton window at the next simulation reset, and the registration is removed when the camera is garbage-collected; no task code is needed. A change in one window redraws the camera view in every window.NewtonVisualizerBase.register_sensor_ui_callback(callback): while a scene sensor is the camera source, each callback is called every UI frame withimguiand that sensor, in the Camera Sensor section after its channel and environment controls, and draws only for the sensors it handles. The environment controls move into_draw_sensor_envs, so that their early return for a single-environment sensor does not skip the callbacks. Everything foveated stays inisaaclab_fovi.ViewerGazeControls.cmf_a_values(0.001° to 1000° in decades by default), plus the camera's configuredcmf_a. Assigning that class attribute changes the stops for every camera; the sliders read it as they draw.ViewerGazeControlsis exported fromisaaclab_fovi.sensorsand documented for this.FoveatedCamera.set_cmf_a(cmf_a_deg)changes the CMF constant at runtime. It rewrites the rendered rays in place and caches one retina per value until the camera is initialized again, so switching back reuses the cached retina instead of building it. A value's retina is built only when the slider first reaches it. It is supported for Newton cameras whose sample count does not depend oncmf_a(the warped-Cartesian styles and the_fixnisotropic ones); other cameras raise, and their controls show the value as fixed with the reason. OVRTX and Isaac RTX read the retina's lens textures once, when the renderer loads the stage.Example (
examples/sensors/foveated_camera.py)--cmf_a_values 0.2,2,20sets the foveation selector's stops (ViewerGazeControls.cmf_a_values), with the eye's owncmf_aadded. The values are comma-separated, so the overrides after the flag stay overrides.cmf_areadout repeated the foveation selector. It covers the view once it opens, and again when the view is resized; otherwise the user can move or resize it. Dragging on it, or I/J/K/L, steers the gaze only; the mount never moves with it.main, the example'sisaacsim_rtxpreset (renderer=isaacsim_rtx) crashes while Kit starts: the example's top-level imports,pxrand theFoveatedCameraandBaseVisualizerclasses, load the pip USD library beforelaunch_simulationstarts Kit, whose own USD then fails to load. The example now importspxrin the clutter helper, which runs after launch, and the two classes only for type checking, as themicroduck-warehousedemo keeps runtime imports out of module scope. The fix is listed under Fixed inisaaclab's changelog, where the example was added.Docs. The Foveated Camera page describes the controls below Camera Source and the example's interaction, and its Sampling section names the image the camera publishes the foveated camera's cortical view. The API page documents
ViewerGazeControls.cmf_a_values.Type of change
Validation
test_camera_gaze.py. Two drive the controls through a stand-in ImGui: the sliders follow a gaze set elsewhere and set it in every Newton window, a window draws them only while the camera is its source, each camera's widgets get their own ID scope, the foveation selector shows and switchescmf_aamongViewerGazeControls.cmf_a_valuesand keeps the starting value as an option (or shows it as fixed), and each foveated camera adds its controls on reset until it is gone. The third checks that the RTX camera, which OVRTX and Isaac RTX share, refusesset_cmf_a.isaaclab_visualizers'test_newton_task_views.pychecks that sensor UI callbacks draw in the Camera Sensor section, after its channel and environment controls and in registration order, with the selected sensor.test_newton_adapter.py::test_newton_scene_camera_controls_apply_uniformly_to_active_copiesfails only when run in one process aftertest_camera_gaze.py, with or without the visualizer change; each file passes on its own.test_cmf_a_switches_the_retina_at_runtime, checks that building the camera added its viewer controls, then switches a fixed-count camera'scmf_aand checks, on Newton Warp and OptiX, that each sample renders along its new ray, the outputs keep their shape, and switching back restores the first image.CameraCfg, whose only viewer setting is the stockstreaming_view=True: switching the window's Camera Source, the Camera Sensor section shows the foveated camera's controls with it selected, and nothing extra with the ordinary camera or the perspective view.isaaclab example foveated-camera renderer=isaacsim_rtxcrashes at Kit startup onmainand runs on this branch, headless and with the Newton viewer, and the retina follows a gaze set at runtime on Isaac RTX as on Newton. Loading the example module no longer maps any USD library before Kit starts.--cmf_a_values 0.2,2,20the foveation selector has the four stops 0.2, 0.591, 2 and 20; with the defaults, switching the eye to 0.001° and to 1000° rebuilds the retina and renders. A negative value is rejected, and the flag beforerenderer=isaacsim_rtxleaves that override in place.isaaclabCLI.ViewerGazeControlsAPI entry and the updated Foveated Camera page.Checklist
Docker and GPU tests run on demand. Push the commits you want tested, then
comment
run-cion the pull request, orrun-ci ovstageto include kitless OVStage rendering tests for that run.pre-commitchecks withuv run isaaclab --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bump package versions — CI handles that)CONTRIBUTORS.mdor my name already exists there