Repository navigation
Conversation
db5f36c to
5c542e1
Compare
[Medium impact] Adds camera tracking to visualization system. Fix Kit tracking with a scene-camera panel before merging. FindingsSummaryAdds shared camera origins and asset/body tracking for Newton GL, Newton RTX, and Kit.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Display update] --> C[Update camera tracking]
B[Perspective capture] --> C
C --> D{Sensor view selected?}
D -- Yes --> E[Skip tracking]
D -- No --> F{Already updated this physics step?}
F -- Yes --> E
F -- No --> G[Read tracked asset position]
G --> H[Add configured eye and target offsets]
H --> I[Set perspective camera]
I --> J[Render frame]
E --> J
Reviews (1) · Last reviewed commit: db5f36c · Reviewed by Greptile |
| if self.current_image_view is not None and self.current_image_view.camera is not None: | ||
| return |
There was a problem hiding this comment.
When Kit displays a scene-camera panel, BaseVisualizer.initialize() selects a sensor-backed current_image_view, so this guard skips every tracking update. Kit's main viewport and render_rgb_array() still use a separate perspective camera. Both now stop following the asset.
Limit this guard to viewers where selecting a sensor replaces the perspective view. Kit should keep tracking its viewport without moving the sensor.
Knowledge Base Used: Rendering pipelines and visualizer adapters
| step = self._sim.get_physics_step_count() | ||
| if self._camera_tracking_step == step: | ||
| return |
There was a problem hiding this comment.
The step-only cache keeps the old camera origin after an environment reset. ManagerBasedEnv.reset() can move the robot, call sim.forward(), and rerender without advancing physics or calling the visualizer's reset(). If tracking already ran at that step, this return leaves the camera at its pre-reset position until physics advances.
Invalidate tracking when environment resets change poses. Add coverage through the environment reset API rather than only calling viz.reset() directly.
Knowledge Base Used: Simulation, rendering, and sensors
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Scope and over-engineering (2), Compatibility and deprecation (3), Style consistency (1), Test quality (1). Other reviewed categories look good.
- PR description: The non-breaking claim contradicts three Kit contract changes; document them and their deprecation bridges, while retaining the supplied focused, live, and recording validation evidence.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: Minimal implementation: BaseVisualizer and VisualizerCfg own origin resolution; delete
_interactive_scene, merge Kit’s duplicate eye/target arithmetic into the base pose computation, and keep SimulationContext dispatch plus ImageView capture hooks. No added source modules require accounting. Replace with one smaller PR: retain the existing 15 files and validate shared tracking, Kit compatibility, Newton selection, capture, docs, and changelogs. - API: API changes look good.
- Compatibility and deprecation: Breaking changes: Kit scene-camera configurations disable viewport tracking, viewer_origin changes tensor to list, and tolerated invalid origins now raise; preserve behavior and type or add complete deprecation bridges.
- Implementation: Implementation looks good.
- Style consistency: The moved origin configuration docstrings omit RST literal markup used by the deleted Kit fields and adjacent configuration documentation; mark literal values consistently.
- Test quality: Distinct tracking and Kit synchronization contracts are covered, but the invalid-origin parameter rows accept either error and can pass through the wrong guard; bind each row to its expected message.
Significant concerns. Posted 7 inline findings.
Automated review; human maintainers own approval decisions.
| """ | ||
| if not self.is_initialized or self.cfg.origin_type == "world": | ||
| return | ||
| if self.current_image_view is not None and self.current_image_view.camera is not None: |
There was a problem hiding this comment.
🔴 Critical · Compatibility — Scene camera view disables Kit tracking
Kit's image views only hold scene cameras, so this guard makes tracking a no-op whenever a SceneCameraCfg is configured, silently stopping viewport tracking that previously ran every step. Scope it to Newton.
| @@ -61,6 +61,12 @@ def __init__(self, cfg: VisualizerCfg): | |||
| self._live_plots_step_counter: int = 0 | |||
| self._reset_requested: bool = False | |||
| self._sim_time = 0.0 | |||
| self._interactive_scene = None | |||
There was a problem hiding this comment.
🟡 Warning · Scope Complexity — Delete unused tracking scene field
_interactive_scene is only read inside the method that assigns it, and Kit no longer uses it. Use a local variable and remove the attribute, its initialization, and the close() teardown line.
| elif self.cfg.origin_type in ("env", "asset"): | ||
| self._interactive_scene = self._sim.get_scene_data_provider().get_interactive_scene() | ||
| if self._interactive_scene is None: | ||
| raise ValueError("Camera origin tracking requires an interactive scene.") |
There was a problem hiding this comment.
🟡 Warning · Compatibility — Tolerant origin fallbacks now raise
Kit previously warned and fell back for a missing scene or unknown origin_type, ignored unknown asset names, and used the first body match; all now raise during initialize without a deprecation path.
| """Environment containing the camera origin when origin_type is env or asset.""" | ||
|
|
||
| origin_track_path: str | None = None | ||
| """Asset root ("robot") or body ("robot/torso_link") to track for an asset origin. |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Config literals lack RST markup
The deleted Kit docstrings and sibling streaming fields mark literals with double backticks; these moved fields write world, asset, and "robot/torso_link" as plain text, so Sphinx renders them unformatted.
| origin_env_index=env_index, | ||
| ) | ||
| ) | ||
| with pytest.raises(ValueError, match="origin_env_index|origin_track_path"): |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Invalid-origin rows share permissive regex
Both parametrized rows accept either error message, so each case passes even when the other validation guard raised. Pass the expected message per row.
| @@ -456,12 +451,12 @@ def reapply_origin(self) -> None: | |||
| self._setup_initial_camera_view() | |||
|
|
|||
| @property | |||
| def viewer_origin(self) -> torch.Tensor | None: | |||
| def viewer_origin(self) -> list[float] | None: | |||
There was a problem hiding this comment.
🟡 Warning · Compatibility — viewer_origin return type changed
This public property now returns list[float] instead of torch.Tensor, breaking callers that use tensor arithmetic, dtype, or device. Keep the tensor contract or run a full deprecation cycle with migration notes.
| eye = np.array(self.cfg.eye, dtype=float) + origin | ||
| target = np.array(self.cfg.lookat, dtype=float) + origin | ||
| self.set_camera_view(tuple(float(v) for v in eye), tuple(float(v) for v in target)) | ||
| super()._apply_viewer_origin_to_camera() |
There was a problem hiding this comment.
🟡 Warning · Scope Complexity — Duplicate absolute pose computation
This override recomputes eye and target that the base method derives from the same origin and offsets, so the viewport and renderer cameras can drift. Compute the pose once and reuse it.
684060b to
a828fb6
Compare
a828fb6 to
d17c1de
Compare
|
@matthewtrepte |
Yes, pls close this PR |
Summary
Adds asset-following perspective cameras to Newton GL and Newton RTX, inspired by the camera-tracking behavior in Isaac Lab's main branch (Isaac Lab 2.x).
The existing Kit origin options move into
VisualizerCfgand the shared visualizer implementation. A camera can use world coordinates, an environment origin, an asset root, or a named body. Tracking translates the configured eye and look-at offsets in world axes; it does not rotate them with the asset.Example
Use
origin_track_path="robot/torso_link"to follow one body, ororigin_type="env"to offset the camera from an environment origin. The same options work withNewtonGLVisualizerCfgandKitVisualizerCfg. Scene-camera sensors retain their own poses.Changes
KitVisualizer.viewer_origintensor API, including the asset tensor device; only callers of that compatibility property use Torch.Kit retains its prior world-origin fallback for a missing scene or unknown origin type, ignores unknown asset names, and uses the first matching body. Invalid environment indices and missing asset paths still raise.
Tracking is opt-in. The default world origin does not read scene state. Asset tracking reads the selected position onto the CPU when updating the camera.
Depends on / setup
isaac-sim/IsaacLabdevelopjnskkmhr/IsaacLabjnskkmhr/PR_viewer_asset_trackingisaac-sim/IsaacLabTest plan
Focused tests at
684060b76used the branch's own uv environment, one file per process (uv run --no-sync python -m pytest -q <file>):source/isaaclab/test/visualizers/test_visualizer.pysource/isaaclab/test/sim/test_simulation_context_visualizers.pysource/isaaclab_visualizers/test/test_kit_visualizer_scene_partitioning.pysource/isaaclab_visualizers/test/test_newton_adapter.pyThe orchestration tests used the lockfile versions of optional
rerunandviserdependencies. Full repository formatting/lint and changelog checks passed.The reset/capture regression exercises
ManagerBasedEnv.reset()without advancing physics and fails on the pre-fix code. Restoring the sensor-view guard also makes the Kit viewport test fail.Earlier feature validation (not rerun for this review follow-up) used
Isaac-Velocity-Flat-G1, two environments, a zero-action agent, and tracking of environment 1. Each viewer ran 80 environment steps with a reset after step 40:robot/torso_linkOffline verification used the actual
VideoRecorderCfg(source="viz:<type>")path withheadless=Trueand no--vizwindow. Both GL and RTX produced 80-frame, 640×480 MP4s at 50 FPS. All 80 captured camera positions matched the tracked robot root plus the configured offset within 1.2×10⁻⁷ m, including a reset halfway through. The robot root moved approximately 0.83 m along x over the recording.Both encoded videos were decoded and their frame counts verified. Frames 0, 39, 40, and 79 matched the corresponding pre-encode captures with mean absolute pixel error below 3/255 (lossy H.264). These checks exercise camera tracking and recording, not policy locomotion quality.
Offline recording example
Keep the visualizer configuration above and set
headless=True. Add a recorder:Run with
--video viz:newton_rtxand omit--viz. The recording-only renderer reuses the configured asset tracking. Useviz:newton_glfor GL recording. The projectvideoextra supplies the optional encoding dependency.Kit compatibility was covered by the focused tests; a live Kit rendering session was not run. Existing dependency deprecation warnings were reported by the tests.
Type of change
Release backport
developChecklist
uv run isaaclab --format.CONTRIBUTORS.md.