Repository navigation
Add Newton visualizer camera view updates - #6078
Conversation
There was a problem hiding this comment.
🤖 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])) |
There was a problem hiding this comment.
🔵 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) |
There was a problem hiding this comment.
🔵 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.
e54621c to
ed61aad
Compare
Greptile SummaryThis PR fixes a silent drop of
Confidence Score: 4/5Safe 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
Sequence DiagramsequenceDiagram
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)"
Reviews (1): Last reviewed commit: "Add Newton visualizer camera view update..." | Re-trigger Greptile |
ed61aad to
c249ac8
Compare
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 requestedeyeandlookatvalues inNewtonVisualizerCfgand applies them to the active Newton viewer camera when available.No new dependencies are required.
Fixes #
Type of change
Screenshots
Not applicable.
Checklist
contributing.html)
pre-commitchecks with./isaaclab.sh --format