Skip to content

Add General Visualizer Marker Support for Newton based Visualizers#6532

Open
matthewtrepte wants to merge 3 commits into
isaac-sim:developfrom
matthewtrepte:mtrepte/usd-visualizer-markers
Open

Add General Visualizer Marker Support for Newton based Visualizers#6532
matthewtrepte wants to merge 3 commits into
isaac-sim:developfrom
matthewtrepte:mtrepte/usd-visualizer-markers

Conversation

@matthewtrepte

@matthewtrepte matthewtrepte commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

Previously all USD based visualizer markers were not supported by Newton based visualizers, since there wasn't support for general USD -> Newton Mesh conversion.

Newton recently added this API, so we can add general support and remove hardcoded support for specific markers, like the dexcube targets.

Note this PR requires updating Newton to 1.4.0 (which is currently breaking some tests)

Type of change

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

Screenshots

Please attach before and after screenshots of the change if applicable.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@matthewtrepte
matthewtrepte requested a review from ooctipus as a code owner July 15, 2026 05:58
@github-actions github-actions Bot added isaac-lab Related to Isaac Lab team infrastructure labels Jul 15, 2026
@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds generic USD-to-Newton mesh conversion for visualization markers, replacing the previous hardcoded DexCube workaround by leveraging the new newton.usd.get_mesh API (available in newton 1.4.0rc2). The Newton dependency is bumped from a pinned git commit to the 1.4.0rc2 release candidate.

  • Adds _load_usd_mesh with an instanceable-USD fallback that traverses prototype prims, loads vertex/normal/UV data, and bakes the local transform into vertices.
  • Removes the _MeshData dataclass and _create_textured_box_mesh helper in favor of returning Newton Mesh objects directly; guards normals/uvs arrays against None before passing to viewer.log_mesh.
  • Extends the markers demo to exercise Newton/Rerun/Viser visualizers, and removes the Newton-visualizer restriction from the deformables demo (the latter appears unrelated to the stated scope of this PR).

Confidence Score: 3/5

The core USD marker loading path is well-tested and robust, but the deformables demo unconditionally exposes the Newton visualizer to users without any guard, which could cause silent runtime failures in a user-facing script.

The Newton marker implementation is solid and the five new tests cover the critical paths. The main concern is deformables.py: the previous explicit restriction was removed without any corresponding implementation of deformable support in Newton. The Newton RC pin also introduces a pre-release as a hard dependency.

scripts/demos/deformables.py — the Newton visualizer guard was removed; confirm whether Newton now supports deformable bodies before landing this change.

Important Files Changed

Filename Overview
scripts/demos/deformables.py Removes the Newton-visualizer restriction without evidence that Newton now supports deformable bodies; users can now pass --visualizer newton and get a silent or confusing failure.
scripts/demos/markers.py Enables Newton/Rerun/Viser visualizers for the markers demo and adds a local_usd_mesh marker using Newton's internal test asset, which may not be present in wheel-installed environments.
source/isaaclab_visualizers/isaaclab_visualizers/newton/newton_visualization_markers.py Core change: adds _load_usd_mesh for generic USD to Newton mesh conversion, removes hardcoded DexCube path, guards normals/uvs for None. The instanceable-USD fallback does not transform normals for rotated prims.
source/isaaclab_visualizers/test/test_newton_adapter.py Adds five new tests covering USD marker inference, missing-USD fallback, arrow/frame_prim pass-through, and the None-normals/UVs guard in _ensure_mesh_registered.
pyproject.toml Upgrades Newton dependency from a pinned git commit to 1.4.0rc2 (release candidate) to consume the new newton.usd.get_mesh API.
source/isaaclab_visualizers/changelog.d/mtrepte-usd-visualizer-markers.minor.rst New changelog fragment describing the generic USD marker support and removal of the DexCube workaround.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["UsdFileCfg marker_cfg"] --> B["_infer_newton_marker_cfg()"]
    B --> C{"usd_path ends with arrow_x.usd?"}
    C -- Yes --> D["_NewtonMarkerSpec renderer=mesh, mesh_type=arrow"]
    C -- No --> E{"usd_path ends with frame_prim.usd?"}
    E -- Yes --> F["_NewtonMarkerSpec renderer=frame"]
    E -- No --> G["_load_usd_mesh(usd_path)"]
    G --> H{"nusd.get_mesh direct path"}
    H -- success --> I["return newton.Mesh"]
    H -- "ValueError: No prims found" --> J["Instanceable USD fallback: traverse prototypes"]
    J --> K{"Mesh prim found?"}
    K -- Yes --> L["nusd.get_mesh prim + bake xform"]
    L --> I
    K -- No --> M["log warning, return None"]
    H -- "other exception" --> N["outer except, log warning, return None"]
    I --> O["_NewtonMarkerSpec renderer=mesh, mesh_type=usd, preloaded_mesh"]
    M --> P["_NewtonMarkerSpec renderer=none"]
    N --> P
    O --> Q["_ensure_mesh_registered viewer.log_mesh"]
    Q --> R["viewer.log_instances"]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["UsdFileCfg marker_cfg"] --> B["_infer_newton_marker_cfg()"]
    B --> C{"usd_path ends with arrow_x.usd?"}
    C -- Yes --> D["_NewtonMarkerSpec renderer=mesh, mesh_type=arrow"]
    C -- No --> E{"usd_path ends with frame_prim.usd?"}
    E -- Yes --> F["_NewtonMarkerSpec renderer=frame"]
    E -- No --> G["_load_usd_mesh(usd_path)"]
    G --> H{"nusd.get_mesh direct path"}
    H -- success --> I["return newton.Mesh"]
    H -- "ValueError: No prims found" --> J["Instanceable USD fallback: traverse prototypes"]
    J --> K{"Mesh prim found?"}
    K -- Yes --> L["nusd.get_mesh prim + bake xform"]
    L --> I
    K -- No --> M["log warning, return None"]
    H -- "other exception" --> N["outer except, log warning, return None"]
    I --> O["_NewtonMarkerSpec renderer=mesh, mesh_type=usd, preloaded_mesh"]
    M --> P["_NewtonMarkerSpec renderer=none"]
    N --> P
    O --> Q["_ensure_mesh_registered viewer.log_mesh"]
    Q --> R["viewer.log_instances"]
Loading

Reviews (1): Last reviewed commit: "add general support for viz markers on n..." | Re-trigger Greptile

Comment thread scripts/demos/deformables.py Outdated
Comment on lines 29 to 32
conflict_handler="resolve",
)
parser.add_argument("--physics", default="physx", choices=["physx", "newton_mjwarp"], help="Physics backend.")
# Newton visualizer not supported for deformables
parser.add_argument("--visualizer", default="kit", choices=["kit"], help="Visualizer backend.")
add_launcher_args(parser)

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 Premature removal of Newton-visualizer guard for deformables

The original code explicitly blocked the Newton visualizer for deformables with the comment "Newton visualizer not supported for deformables." This PR removes both the --visualizer argument (restricted to ["kit"]) and the parser.set_defaults(visualizer=["kit"]) call, so running ./isaaclab.sh -p scripts/demos/deformables.py --visualizer newton would now accept the Newton visualizer without any guard. If the Newton visualizer still doesn't support deformable bodies, users will get a runtime failure with no helpful error message. The PR description and the rest of the changes only address USD mesh markers, not deformable-body rendering in Newton — is this removal intentional?

Comment thread scripts/demos/markers.py Outdated
Comment on lines +53 to +55

_NEWTON_TEST_USD = os.path.join(os.path.dirname(_newton.__file__), "tests", "assets", "cube_cylinder.usda")

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 Demo relies on Newton's internal test asset — may not be present in production installs

_NEWTON_TEST_USD is resolved at module-import time by joining newton.__file__'s directory with "tests/assets/cube_cylinder.usda". Package builds (e.g. wheel distributions) routinely strip the tests/ directory, so this path will silently not exist in many environments. When _load_usd_mesh fails on a missing file, the marker degrades to renderer="none" and only emits a log warning — meaning the demo's "local_usd_mesh" marker disappears without any user-facing explanation.

@matthewtrepte
matthewtrepte force-pushed the mtrepte/usd-visualizer-markers branch 2 times, most recently from 7fe304c to e706ea2 Compare July 20, 2026 23:21
@matthewtrepte
matthewtrepte requested a review from a team July 20, 2026 23:21
Replace the hardcoded per-asset USD detection (dexcube textured box,
fallback-to-none for unknown paths) with a generic loader that opens
any UsdFileCfg path via Usd.Stage and converts the first UsdGeom.Mesh
prim to a Newton Mesh using newton.usd.get_mesh. Material properties
(color, texture) are resolved automatically from the USD material.

Remove _create_textured_box_mesh, _MeshData, _DEX_CUBE_TEXTURE_URL,
and the "textured_box" mesh_type. Add "usd" mesh_type backed by a
preloaded_mesh field on _NewtonMarkerSpec. Fix _ensure_mesh_registered
to handle None normals/uvs returned by newton.Mesh.create_from_usd.
Remove --physics and --visualizer args from scripts/demos/deformables.py
and scripts/demos/markers.py, restoring the standard AppLauncher pattern
and simulation_app.is_running() loop. The deformables script now uses
PhysX unconditionally; the Newton conditional import branches are dropped.

Also trim verbose docstring paragraphs from _load_usd_mesh and remove the
misleading "uniform scale" qualifier from the normals-not-transformed note.
@matthewtrepte
matthewtrepte force-pushed the mtrepte/usd-visualizer-markers branch from e706ea2 to 76a4684 Compare July 21, 2026 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant