Skip to content

Add Newton visualizer camera view updates - #6078

Merged
maxkra15 merged 1 commit into
isaac-sim:developfrom
maxkra15:max/newton-visualizer-camera-view
Jun 9, 2026
Merged

maxkra15 merged 1 commit into
isaac-sim:developfrom
maxkra15:max/newton-visualizer-camera-view

Conversation

@maxkra15

@maxkra15 maxkra15 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

This PR updates the Newton visualizer so set_camera_view(eye, target) applies camera updates consistently.

Previously, camera view updates from SimulationContext.set_camera_view(...) could be ignored when the Newton visualizer was not fully initialized, and the visualizer config was not kept in sync with the requested camera pose. This change stores the requested eye and lookat values in NewtonVisualizerCfg and applies them to the active Newton viewer camera when available.

No new dependencies are required.

Fixes #

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots

Not applicable.

Checklist

@maxkra15
maxkra15 requested a review from ooctipus June 9, 2026 17:45
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Jun 9, 2026

@isaaclab-review-bot isaaclab-review-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 IsaacLab Review Bot — PR #6078

Summary: This PR fixes a bug where set_camera_view() was silently ignored when the Newton visualizer was not yet initialized. The new implementation stores the requested eye/lookat in NewtonVisualizerCfg and delegates to _apply_camera_pose(), which safely no-ops when _viewer is None.

Verdict: ✅ Well-structured fix. The approach is sound — storing camera state in cfg ensures it persists and is applied when the viewer becomes available (during initialize()). The test is focused and verifies both the state mutation and the viewer camera update.

Findings

# Severity Finding
1 🔵 Suggestion Consider adding a test for set_camera_view when _viewer is None (pre-init path)
2 🔵 Suggestion Changelog CI check failing — verify fragment naming convention
3 🟡 Warning Test accesses private attributes (_viewer, _last_camera_pose) directly

Details

1. Missing test for pre-initialization case — The key behavior improvement is that set_camera_view now stores the pose even before the viewer is ready. A test with visualizer._viewer = None asserting cfg.eye and cfg.lookat are still updated would document this important invariant.

2. Changelog CI failure — The "Check changelog fragments" check is failing. Verify the fragment file newton-visualizer-camera-view.minor.rst matches the expected naming convention for this CI workflow.

3. Test relies on internals — The test directly sets visualizer._viewer and asserts visualizer._last_camera_pose. This is pragmatic for unit testing, but if _apply_camera_pose internals change, the test breaks. Acceptable given the method's stability.

Overall: Clean, minimal, well-tested change. Good work! 👍


Update (c249ac8):

  • ✅ Finding #1 Fixed: Added test_newton_visualizer_set_camera_view_updates_cfg_without_viewer() covering the pre-init path.
  • ✅ Finding #2 Fixed: Changelog fragment renamed to newton-visualizer-camera-view.rst (matches convention).
  • Finding #3: Unchanged (acceptable as noted).
  • No new issues introduced. Tests are well-structured and cover both pre-init and active-viewer scenarios. LGTM 👍

logger.debug("[NewtonVisualizer] set_camera_view() ignored because visualizer is not initialized.")
return
self._apply_camera_pose((tuple(eye), tuple(target)))
eye_t = (float(eye[0]), float(eye[1]), float(eye[2]))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Suggestion: Since _apply_camera_pose early-returns when self._viewer is None, the cfg update still persists correctly. This is a nice improvement over the old guard — the camera pose is stored regardless of initialization state and will be picked up during initialize() via self.cfg.eye/self.cfg.lookat. Well done.

Minor: consider adding a brief inline comment noting that _apply_camera_pose is a safe no-op when the viewer isn't ready, for readers unfamiliar with that method.

assert (viewer.camera.pos.x, viewer.camera.pos.y, viewer.camera.pos.z) == (1.0, 2.0, 3.0)
assert viewer.camera.look_at_calls == [(0.0, 0.0, 1.0)]
assert visualizer.cfg.eye == (1.0, 2.0, 3.0)
assert visualizer.cfg.lookat == (0.0, 0.0, 1.0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Suggestion: Consider adding a complementary test case where visualizer._viewer = None to verify the pre-initialization path — i.e., that cfg.eye and cfg.lookat are still updated even when no viewer is available. This documents the core bug fix.

@maxkra15
maxkra15 force-pushed the max/newton-visualizer-camera-view branch from e54621c to ed61aad Compare June 9, 2026 17:48
@greptile-apps

greptile-apps Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a silent drop of set_camera_view calls that occurred when the Newton visualizer was not yet initialized. The fix stores the requested eye and lookat values directly into NewtonVisualizerCfg before delegating to _apply_camera_pose, so that _resolve_initial_camera_pose picks up the correct values when the viewer is eventually created.

  • newton_visualizer.py: Removes the _is_initialized early-return guard; always writes cfg.eye/cfg.lookat before calling _apply_camera_pose, which itself already handles a None viewer gracefully.
  • test_newton_adapter.py: Adds a unit test verifying cfg sync and camera calls, but only for the post-init path (viewer already present); the pre-init scenario that motivates the fix is not covered.

Confidence Score: 4/5

Safe to merge; the implementation correctly handles both pre- and post-init camera view updates with no data loss.

The implementation logic is sound — updating cfg.eye/cfg.lookat before delegating to _apply_camera_pose ensures the initial pose is correctly resolved from config during initialize(). The only gap is that the added test exercises the viewer-already-present path rather than the pre-init path that the PR description identifies as the root cause.

The test file would benefit from an additional test case covering set_camera_view called while _viewer is None.

Important Files Changed

Filename Overview
source/isaaclab_visualizers/isaaclab_visualizers/newton/newton_visualizer.py Removes the _is_initialized guard in set_camera_view, always updating cfg.eye/cfg.lookat before delegating to _apply_camera_pose; when the viewer is not yet available the cfg update ensures _resolve_initial_camera_pose picks up the new values on init.
source/isaaclab_visualizers/test/test_newton_adapter.py Adds test_newton_visualizer_accepts_set_camera_view which only covers the post-init path (viewer already set); the pre-init scenario that is the actual bug fix is not exercised by any test.
source/isaaclab_visualizers/changelog.d/newton-visualizer-camera-view.minor.rst New changelog entry for the set_camera_view support addition; content is accurate and correctly categorised as a minor change.

Sequence Diagram

sequenceDiagram
    participant SC as SimulationContext
    participant NV as NewtonVisualizer
    participant CFG as NewtonVisualizerCfg
    participant AP as _apply_camera_pose
    participant VW as NewtonViewerGL

    Note over SC,VW: Pre-init path (viewer not yet created)
    SC->>NV: set_camera_view(eye, target)
    NV->>CFG: "cfg.eye = eye_t"
    NV->>CFG: "cfg.lookat = target_t"
    NV->>AP: _apply_camera_pose(pose)
    AP-->>NV: return (viewer is None, no-op)

    SC->>NV: initialize(scene_data_provider)
    NV->>VW: create NewtonViewerGL(...)
    NV->>NV: _resolve_initial_camera_pose()
    NV->>CFG: read cfg.eye, cfg.lookat (updated values)
    NV->>AP: _apply_camera_pose(initial_pose)
    AP->>VW: "camera.pos = PygletVec3(*cam_pos)"
    AP->>VW: camera.look_at(cam_target)
    AP->>NV: "_last_camera_pose = (cam_pos, cam_target)"

    Note over SC,VW: Post-init path (viewer running)
    SC->>NV: set_camera_view(eye, target)
    NV->>CFG: "cfg.eye = eye_t"
    NV->>CFG: "cfg.lookat = target_t"
    NV->>AP: _apply_camera_pose(pose)
    AP->>VW: "camera.pos = PygletVec3(*cam_pos)"
    AP->>VW: camera.look_at(cam_target)
    AP->>NV: "_last_camera_pose = (cam_pos, cam_target)"
Loading

Reviews (1): Last reviewed commit: "Add Newton visualizer camera view update..." | Re-trigger Greptile

@maxkra15
maxkra15 force-pushed the max/newton-visualizer-camera-view branch from ed61aad to c249ac8 Compare June 9, 2026 17:51
@maxkra15
maxkra15 merged commit ea1a671 into isaac-sim:develop Jun 9, 2026
60 of 61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants