Skip to content

Add asset tracking to Newton visualizer cameras - #8586

Closed
jnskkmhr wants to merge 6 commits into
isaac-sim:mainfrom
jnskkmhr:jnskkmhr/PR_viewer_asset_tracking
Closed

jnskkmhr wants to merge 6 commits into
isaac-sim:mainfrom
jnskkmhr:jnskkmhr/PR_viewer_asset_tracking

Conversation

@jnskkmhr

@jnskkmhr jnskkmhr commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

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 VisualizerCfg and 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

from isaaclab_visualizers.newton import NewtonRTXVisualizerCfg

sim_cfg.visualizer_cfgs = [
    NewtonRTXVisualizerCfg(
        eye=(2.0, 2.0, 2.0),
        lookat=(0.0, 0.0, 0.0),
        origin_type="asset",
        origin_track_path="robot",
        origin_env_index=0,
    ),
]

Use origin_track_path="robot/torso_link" to follow one body, or origin_type="env" to offset the camera from an environment origin. The same options work with NewtonGLVisualizerCfg and KitVisualizerCfg. Scene-camera sensors retain their own poses.

Changes

  • Store internal camera origins as CPU coordinate lists, reading positions directly from Warp arrays. Preserve the existing KitVisualizer.viewer_origin tensor API, including the asset tensor device; only callers of that compatibility property use Torch.
  • Unify Kit and Newton origin resolution and asset/body tracking. Compute each absolute pose once and pass it to both Kit perspective cameras. Kit keeps tracking its viewport when a sensor panel is selected; Newton suspends perspective tracking when its selected view is a sensor.
  • Update tracking before display and before on-demand perspective capture, so video recording follows the selected asset. Cache the update within a physics step and invalidate it on environment-reset forwarding or camera selection, including cached perspective captures.
  • Preserve relative offsets when an adapter stores absolute camera poses in its config.
  • Add focused coverage for origin selection, repeated updates, reset/capture behavior, sensor-view isolation, and invalid configuration.
  • Document usage and add changelog fragments with minor-version markers for both affected packages.

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

Repo PR / branch Relationship
isaac-sim/IsaacLab develop Base branch; no prerequisite PRs
jnskkmhr/IsaacLab jnskkmhr/PR_viewer_asset_tracking This feature branch
isaac-sim/IsaacLab #8583 Independent DLSS presentation fix; either PR can merge first
git fetch https://github.com/jnskkmhr/IsaacLab.git jnskkmhr/PR_viewer_asset_tracking
git switch --detach FETCH_HEAD

Test plan

Focused tests at 684060b76 used the branch's own uv environment, one file per process (uv run --no-sync python -m pytest -q <file>):

Test file Result
source/isaaclab/test/visualizers/test_visualizer.py 25/25 passed
source/isaaclab/test/sim/test_simulation_context_visualizers.py 36/36 passed
source/isaaclab_visualizers/test/test_kit_visualizer_scene_partitioning.py 14/14 passed
source/isaaclab_visualizers/test/test_newton_adapter.py 49/49 passed

The orchestration tests used the lockfile versions of optional rerun and viser dependencies. 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:

Viewer Tracked position Captures checked Maximum camera-position error
Newton GL Robot root 16 0.0 m at the sampled poses
Newton RTX robot/torso_link 16 0.0 m at the sampled poses

Offline verification used the actual VideoRecorderCfg(source="viz:<type>") path with headless=True and no --viz window. 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:

from isaaclab.envs.utils.video_recorder_cfg import VideoRecorderCfg

env_cfg.video_recorders = [
    VideoRecorderCfg(
        source="viz:newton_rtx",
        output_dir="videos",
        video_length=200,
    ),
]

Run with --video viz:newton_rtx and omit --viz. The recording-only renderer reuses the configured asset tracking. Use viz:newton_gl for GL recording. The project video extra 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

  • New feature (non-breaking change which adds functionality)

Release backport

  • Backport this pull request to the active release branch after it merges into develop

Checklist

  • I have read and understood the contribution guidelines.
  • I have run uv run isaaclab --format.
  • I have made corresponding documentation changes.
  • My changes generate no new warnings (the validation runs include dependency warnings).
  • I have validated the changed behavior and applied the test-audit criteria to new tests.
  • I have added changelog fragments for every touched source package.
  • I have added my name to CONTRIBUTORS.md.

@github-actions github-actions Bot added documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team labels Oct 14, 2026
@jnskkmhr
jnskkmhr requested a balanced review from Copilot October 14, 2026 23:02

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@jnskkmhr
jnskkmhr marked this pull request as ready for review October 15, 2026 02:30
@jnskkmhr
jnskkmhr requested a review from a team October 15, 2026 02:30
@jnskkmhr
jnskkmhr force-pushed the jnskkmhr/PR_viewer_asset_tracking branch from db5f36c to 5c542e1 Compare October 15, 2026 02:32
@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] Adds camera tracking to visualization system.

Fix Kit tracking with a scene-camera panel before merging.

Findings

  1. P1 Kit camera stops following ▶
  2. P2 Reset frames use old camera ▶

Summary

Adds shared camera origins and asset/body tracking for Newton GL, Newton RTX, and Kit.

  • Perspective cameras follow a chosen environment or asset across visualizers.

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
Loading

Reviews (1) · Last reviewed commit: db5f36c · Reviewed by Greptile

Comment on lines +391 to +392
if self.current_image_view is not None and self.current_image_view.camera is not None:
return

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.

P1 Kit camera stops following

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

Comment on lines +393 to +395
step = self._sim.get_physics_step_count()
if self._camera_tracking_step == step:
return

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.

P2 Reset frames use old camera

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

@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.

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:

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.

🔴 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

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.

🟡 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.")

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.

🟡 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.

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.

🟡 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"):

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.

🟡 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:

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.

🟡 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()

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.

🟡 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.

@jnskkmhr
jnskkmhr force-pushed the jnskkmhr/PR_viewer_asset_tracking branch from 684060b to a828fb6 Compare October 15, 2026 17:11
@jnskkmhr
jnskkmhr force-pushed the jnskkmhr/PR_viewer_asset_tracking branch from a828fb6 to d17c1de Compare October 15, 2026 19:11
@maxkra15 maxkra15 self-assigned this Oct 28, 2026
@maxkra15
maxkra15 self-requested a review October 28, 2026 12:43
@jnskkmhr

Copy link
Copy Markdown
Contributor Author

@matthewtrepte
Is your viewer PR that has asset tracking already good in shape ? In that case, I will close this PR

@matthewtrepte

Copy link
Copy Markdown
Collaborator

@matthewtrepte Is your viewer PR that has asset tracking already good in shape ? In that case, I will close this PR

Yes, pls close this PR

@jnskkmhr jnskkmhr closed this Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants