Repository navigation
Add tracking cameras that follow a robot to the Newton GL visualizer - #8620
matthewtrepte wants to merge 23 commits into
Conversation
A perspective view can now frame an environment or follow an asset: env_index places it relative to an environment origin, and track_path follows an asset's position and, with follow_heading, its smoothed yaw. CameraFollower turns such a view into world poses and reseeds the heading when an environment resets. Visualizers that declare only task views get a free view beside them, and the scene cameras they would find are kept. Add the viz:<type>:tracking video source, which records the first task view whichever view the window shows. Builds on the tracking views of isaac-sim#7760 by Antoine Richard.
Each perspective view renders itself, so a task view appears in Camera View and the interactive view stays free. A recorder captures a task view by borrowing the viewer camera for one frame and handing it back, so it does not need the window to show that view. Nothing is created in the scene.
Fixed environment views and robot-following views for the locomotion tasks, with the framings of isaac-sim#7760. Each task keeps its own viewport pose.
[Medium impact] The changes affect Newton GL viewing and recording across tasks that declare tracking cameras. Fix the conflicting camera settings in reorient play mode before merging. Findings
SummaryAdds Newton GL tracking cameras, live camera controls, and a recording source independent of the selected window view.
matthewtrepte explicitly limits tracking cameras to Newton GL because Kit is being removed; the earlier Kit lens finding is therefore no longer outstanding. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
C[TrackingCameraCfg] --> F[CameraFollower]
S[Scene asset pose] --> F
F --> V[Newton GL viewer camera]
V --> W[Window]
V --> R[Tracking recording]
P[Saved viewer pose] --> B[Restore after recording]
R --> B
Reviews (4) · Last reviewed commit: "Merge main into mtrepte/newton-gl-tracke..." · Reviewed by Greptile |
| sim_time = self._sim.get_physics_step_count() * self._sim.get_physics_dt() | ||
| pose = follower.pose(max(sim_time - self._follow_time, 0.0)) | ||
| self._follow_time = sim_time |
There was a problem hiding this comment.
Recorded heading stops following
When the window shows one smoothed task view and recording captures another, both followers share _follow_time. The first update consumes the elapsed time, so the second gets dt=0 when both render at the same physics step. Its heading stops updating on those frames and can remain frozen when this happens every frame. Store the previous update time per follower instead.
| # task views only add to the scene cameras the visualizer would find on its own | ||
| task_views_only = bool(visualizer.cfg.cameras) and all( | ||
| isinstance(camera, PerspectiveCameraCfg) and camera.is_task_view | ||
| for camera in visualizer.cfg.cameras | ||
| ) | ||
| if visualizer.cfg.cameras is None or task_views_only: |
There was a problem hiding this comment.
Explicitly constructing NewtonGLVisualizerCfg(cameras=[PerspectiveCameraCfg(env_index=0)], streaming_view=True) disables scene-camera discovery. VisualizerCfg.__post_init__ overwrites streaming_view with False because the list contains no SceneCameraCfg, so execution never reaches this new task_views_only branch. Preserve the existing streaming setting for task-only camera lists so adding a task view does not remove scene cameras.
| last, self._last_position = self._last_position, position | ||
| reset = self._yaw is None or last is None or math.dist(position, last) > _RESET_JUMP | ||
| tau = self.cfg.heading_smoothing_time_constant | ||
| if tau > 0.0 and not reset: | ||
| yaw = self._yaw + -math.expm1(-dt / tau) * math.remainder(yaw - self._yaw, math.tau) |
There was a problem hiding this comment.
A reset only clears heading smoothing when the robot moves more than one meter. The velocity tasks can reset near the same position while choosing a new heading, so this check misses those resets and carries the previous episode's camera heading into the next one. The camera then swings toward the new heading instead of starting there. Clear the follower's heading from an actual environment reset signal rather than relying only on distance.
Create each task view's follower when the viewer initializes, so a bad env_index or track_path fails there, and warn when the framed environment is not visible. Keep the one-owner check on a perspective view's renderer, give each follower its own clock, leave the streaming choice alone when a configuration only declares task views, and drop a branch no caller reaches.
A velocity-task environment can reset near its old position with a new heading, which the distance check misses. Also treat a yaw change no robot turns at (over 10 rad/s) as a reset.
Say what a task view follows or frames instead of numbering it as another perspective view.
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Implementation (1), Style consistency (4), Test quality (2). Other reviewed categories look good.
- PR description: Correct the body’s Newton-GL-only limit: RTX also applies task-view poses, while only tracking recording is GL-gated; the remaining scope and validation claims match the diff.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: No over-engineering issues.
- API: API changes look good.
- Compatibility and deprecation: No breaking changes identified.
- Implementation: Task views without a registered interactive scene leave the follower map empty and fail during rendering; reject that configuration during initialization or handle the missing follower.
- Style consistency: The documentation incorrectly excludes RTX task views; state that RTX displays them while tracking recording remains GL-only.
- Test quality: The standalone Kit tracking failure duplicates the parametrized construction-error owner; merge it there, while retaining the distinct follower and camera hand-back coverage.
Minor fixes needed. Posted 7 inline findings.
Automated review; human maintainers own approval decisions.
| The interactive view stays free: a free perspective view at the visualizer's own ``eye`` and ``lookat`` is | ||
| added before the task view, and the **Camera View** selector switches between them. While a task view is | ||
| selected the window follows the robot, and selecting the free view hands the camera back. Record a task view, | ||
| whichever view the window shows, with ``--video viz:newton_gl:tracking``. Newton GL supports task views; the |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Doc contradicts RTX task-view support
NewtonVisualizerBase.initialize builds followers for RTX and NewtonRTXVisualizer._render_frame applies task-view poses, so "the other visualizers ignore them" is wrong; only viz:<type>:tracking recording is GL-gated. Correct this sentence.
| if kind == "viz" and parts[1:] in ([], ["streaming_view"]) and name in (*VISUALIZER_TYPES, *VISUALIZER_ALIASES): | ||
| if ( | ||
| kind == "viz" | ||
| and parts[1:] in ([], ["streaming_view"], ["tracking"]) |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Grammar error omits tracking form
tracking is now accepted, but the ValueError below still lists only 'viz:<type>:streaming_view', so a typo reports a grammar that contradicts the parser and the updated docstring. Add the new form.
| raise ValueError("heading_smoothing_time_constant must be finite and non-negative.") | ||
|
|
||
|
|
||
| def with_free_view(cameras: list, eye: tuple, lookat: tuple, focal_length: float) -> list: |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Bare collection annotations on new helper
with_free_view(cameras: list, eye: tuple, lookat: tuple) -> list drops the concrete types the guide requires; adjacent configs use tuple[float, float, float]. Also place it with the module's public functions, before the config classes.
| assert viz.render_calls == 0 | ||
|
|
||
|
|
||
| def test_a_visualizer_without_task_views_cannot_record_tracking(): |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Duplicates parametrized invalid-source owner
test_invalid_source_raises already owns construction-time source failures with the same (source, env, error, message) shape. Add a viz:kit:tracking row there instead of a standalone near-duplicate test.
| raise ValueError("A perspective image view must have exactly one rendering owner.") | ||
| view.render = partial(self._capture_view, view) | ||
| source = view.cfg.source | ||
| if source.is_task_view and scene is not None: |
There was a problem hiding this comment.
🟡 Warning · Implementation — Follower guard not repeated by consumers
Followers are created only when an interactive scene exists, yet _apply_view_pose and both _render_frame overrides index self._followers[view] for every task view, so a scene-less run raises KeyError. Guard the consumers or reject earlier.
| def render_task_view_rgb_array(self) -> np.ndarray: | ||
| """Download the first perspective view that is tied to an environment or an asset, whatever the window shows.""" | ||
| view = next( | ||
| (v for v in self._image_views if v.camera is None and getattr(v.cfg.source, "is_task_view", False)), None |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — getattr hides known is_task_view attribute
A view with camera is None always carries a PerspectiveCameraCfg, and initialize reads is_task_view directly. The guide forbids getattr defaults for known attributes; use direct access here and at lines 962 and 1313.
| assert viz.current_image_view is free and viz._last_render_step == -1 | ||
|
|
||
|
|
||
| def test_the_task_view_recording_picks_the_first_tied_view_and_reports_none(): |
There was a problem hiding this comment.
🟡 Warning · Test Quality — Name promises unexercised selection behavior
The name claims it picks the first tied view and reports none, but the fixture holds a single tied view and the second case asserts a RuntimeError. Rename and add a second distinguishable task view.
Report the tracking form in the invalid video source error, correct the docs on which visualizers show task views, type and place the free-view helper, give a task view no pose instead of an error when no follower exists, and read the task-view flag directly. Merge the Kit tracking case into the parametrized invalid-source test and cover each recording case separately.
Kit follows a task view with its viewport, replacing the origin_type, origin_env_index and origin_track_path fields of KitVisualizerCfg: the viewport starts on the first declared view, and follow(), unfollow(), set_follow_env() and set_view_offsets() switch it, from the environment window or code. The deprecated viewer bridge and ViewportCameraController map onto them. Viser gets a Follow task view checkbox, off by default, and an Environment field. Newton GL gets an Environment field beside Camera View. A follower can change its environment at runtime.
…m#8786 Resolve the merge with the visualizer config split: task views are declared in VisualizerCfg.cameras and the Kit origin_* options stay removed from KitBackendCfg. Task declarations use SimulationCfg.visualizer_cfgs, the deprecated viewer bridge builds task views on the new config, and Newton RTX leaves task views out. Bring the follower and Newton GL behavior from isaac-sim#8786: set_track_path, asset_names and body_names on CameraFollower, editable Tracking Camera fields with a reset to the task default, and the Tracking Camera and Perspective view names.
| perspective = [camera for camera in cameras if isinstance(camera, PerspectiveCameraCfg)] | ||
| if perspective and all(camera.is_task_view for camera in perspective): | ||
| return [PerspectiveCameraCfg(eye=eye, lookat=lookat, focal_length=focal_length), *cameras] |
There was a problem hiding this comment.
When cameras starts with a SceneCameraCfg followed by a task view, with_free_view() inserts a free perspective view before both. Newton GL then selects that new view with _select_camera(0). The window and default recording start on the free view instead of the scene camera the user declared first.
Keep the first declared scene camera first when adding the free view.
| if views and views[0].is_task_view: | ||
| first = views[0] | ||
| self.cfg.eye, self.cfg.lookat, self.cfg.focal_length = first.eye, first.lookat, first.focal_length | ||
| self.follow(first.track_path, env_index=first.env_index or 0) |
There was a problem hiding this comment.
Kit copies the first task view's focal_length into cfg, but never applies it to the viewport camera. The follow path only writes the camera position and target. Task views declaring values such as 26.0 or 35.0 therefore keep Kit's existing lens and show a different view width from Newton GL.
Apply the task view's lens settings when activating it so Kit uses the declared framing.
Insert the free view right before the first task view so scene cameras declared ahead of it still open first, and set the viewport camera's focal length when Kit starts following a task view.
|
@greptileai review |
|
run-ci |
Move the task view section after the Newton RTX description, remove the untested-RTX note, the Kit control details and the duplicated migration paragraph, and shorten the visualization concept text.
Viser keeps its main behavior and ignores task views. Mark the two Newton RTX filters as removable together with the RTX visualizer.
Add TrackingCameraCfg, a PerspectiveCameraCfg subclass that frames an environment or follows an asset, and give PerspectiveCameraCfg back its world-coordinate meaning. Rename task views to tracking cameras in the code, tests, docs and changelog fragments.
env_index is now optional. None picks the middle of the visible environments, so the view has neighbors on every side, and the tasks no longer repeat env 0.
|
run-ci |
|
@greptileai review |
| viewer.eye = VISUALIZER_CFG.eye | ||
| viewer.lookat = VISUALIZER_CFG.lookat | ||
| viewer.focal_length = VISUALIZER_CFG.focal_length | ||
| viewer.cameras = [camera.replace() for camera in VISUALIZER_CFG.cameras] |
There was a problem hiding this comment.
play_mode() now sets viewer.cameras even when the viewer already uses view=ImageViewCfg(...). VisualizerCfg.validate_config() rejects that combination, so reorient tasks with a shared display and recording view fail before launch. Leave cameras unset when viewer.view is set. The other reorient play-mode overrides have the same issue.
| visualizer_cfgs=VisualizerCfg( | ||
| eye=(1.4, 1.4, 0.9), | ||
| lookat=(0.5, 0.0, 0.1), | ||
| backend=MultiBackendVisualizerCfg(kit=KitBackendCfg(origin_type="env", origin_env_index=0)), | ||
| cameras=[TrackingCameraCfg(eye=(1.4, 1.4, 0.9), lookat=(0.5, 0.0, 0.1))], |
There was a problem hiding this comment.
The pour task moves its existing eye and lookat into TrackingCameraCfg without keeping the viewport settings. Kit, Viser and Rerun skip tracking cameras, and Newton GL adds a free view at the default pose. The task therefore opens at the generic pose instead of its previous close-up. Keep the existing viewport pose alongside the new tracking camera. The particle-push task has the same issue.
| .. code-block:: python | ||
|
|
||
| from isaaclab.visualizers import PerspectiveCameraCfg, VisualizerCfg | ||
| from isaaclab.visualizers import TrackingCameraCfg, VisualizerCfg |
maxkra15
left a comment
There was a problem hiding this comment.
reorient_manager_env_cfg.py:244: keep cameras unset when viewer.view is set; play_mode currently makes the config invalid. Same fix in the four reorient overrides.
pour_env_cfg.py:535: keep viewport eye/lookat too; Kit and the added free view otherwise lose the close-up. Same for particle push.
camera_follower.py:158-164: reset heading from the environment reset, not motion thresholds. A45deg in-place reset still carries old heading.
visualizer_streaming_camera_view.rst:58: import PerspectiveCameraCfg used below.
| viewer.eye = VISUALIZER_CFG.eye | ||
| viewer.lookat = VISUALIZER_CFG.lookat | ||
| viewer.focal_length = VISUALIZER_CFG.focal_length | ||
| viewer.cameras = [camera.replace() for camera in VISUALIZER_CFG.cameras] |
There was a problem hiding this comment.
P1: Do not populate cameras when viewer.view is already set. A valid shared ImageViewCfg becomes invalid after play_mode: VisualizerCfg.validate_config raises "Choose view or legacy cameras/streaming_sensor_prim_path, not both." The same assignment is added in the four reorient play-mode overrides.
|
|
||
| scene: PourSceneCfg = PourSceneCfg(num_envs=2, env_spacing=2.5) | ||
| sim: sim_utils.SimulationCfg = sim_utils.SimulationCfg( | ||
| # the viewport starts on the first view, framing environment 0; a free view follows it |
There was a problem hiding this comment.
P2: Keep the previous eye/lookat on VisualizerCfg. Moving them only into TrackingCameraCfg makes Kit/Viser/Rerun use the generic pose because they ignore tracking cameras; Newton GL also inserts its free view at that generic pose before the tracking view. UR10 particle push has the same regression.
| x, y, z, w = quat | ||
| yaw = math.atan2(2.0 * (w * z + x * y), 1.0 - 2.0 * (y * y + z * z)) | ||
| last, self._last_position = self._last_position, position | ||
| reset = self._yaw is None or last is None or math.dist(position, last) > _RESET_JUMP |
There was a problem hiding this comment.
P2: Distance/yaw thresholds cannot identify resets. A robot reset in place by45degrees keeps the previous episode’s filtered heading: at dt0.02,tau0.5 the camera yaw is0.0308rad instead of0.7854rad. Clear the relevant follower when its environment resets and cover a small in-place reset.
Description
Adds tracking cameras: a perspective camera that frames an environment or follows a robot, without creating anything in the scene. It replaces the interactive-camera tracking that @AntoineRichard started in #7760, so the interactive camera stays free and nothing grows with the number of environments.
TrackingCameraCfg, aPerspectiveCameraCfgsubclass withenv_index(the middle environment by default),track_path(follow an asset or body),follow_heading, andheading_smoothing_time_constant. Itseyeandlookatare offsets from the environment origin or the tracked asset;PerspectiveCameraCfgkeeps its world-coordinate meaning. The first entry incamerasstarts active, and a free view at the visualizer's own pose is added beside tracking cameras.--video viz:newton_gl:tracking, whichever view the window shows.CameraFollowergainsset_track_path,asset_namesandbody_namesfor this, matching the Tracking Camera in Prototype a unified Newton visualizer with RTX rendering, Policy Ghosts, recording and replay, and a Tracking Camera #8786.main, which splitVisualizerCfgfromKitBackendCfg: tasks declare views insim.visualizer_cfgs, Newton RTX leaves tracking cameras out.Verification
--video viz:newton_gl:trackingon Newton MJWarp with headless Newton GL: Cartpole, Ant, Humanoid, AnymalD, H1, Lift-Franka, Reach-UR10, Open-Drawer-Franka, Reorient-Cube-Shadow, Pendulum-MARL and Shadow-Handover. Framing and tracking match the Add task-owned recording cameras with heading tracking #7760 clips, now with markers.main, the visualizer, follower, adapter, recording and viewer-deprecation unit tests pass; the Newton scene-camera adapter test and thetest/appKit and standalone-script tests fail the same way onmainin my environment (Kit EULA bootstrap, installed Newton version). A real Ant environment with Viser binds the view, starts off at environment 0, and computes the followed pose.--video viz:newton_gl:trackingon the merged branch (4 environments, 300 steps, same seed and policies); framing and following match the earlier clips. The floor shows a plain white grid instead of the grey checker pattern, which I have not traced and which is not a camera change.CameraFollowerreset detection and the Tracking Camera reset; they are fixed and covered by new tests. The reorient tasks lost their task view in play mode in the merge; restored.mainand were not repeated.Limits
Tracking cameras are Newton GL only; the Kit visualizer is not extended since it is being removed. Kit, Viser, Newton RTX and Rerun ignore tracking cameras, and a tracking camera shows one environment.
Type of change
Checklist
./isaaclab.sh --format(ruff only; the docs build was not run)