Skip to content

[Bug Report] CreateShaderPrimFromSdrCommand fails with unexpected keyword argument 'name' #5122

@HarshithDR

Description

@HarshithDR

Describe the bug

When spawning primitives with a visual material (e.g., PreviewSurfaceCfg),
Isaac Lab passes a name keyword argument to CreateShaderPrimFromSdrCommand.
This argument was removed in Omniverse Kit >= 1.13.17, causing a TypeError
and preventing any scene with visual materials from being created.

Steps to reproduce

  1. Run any tutorial that spawns a primitive with a visual material, e.g.:
   ./isaaclab.sh -p scripts/tutorials/00_sim/spawn_prims.py
  1. Observe the following error:
Traceback (most recent call last):
  File "scripts/tutorials/00_sim/spawn_prims.py", line 112, in <module>
    main()
  File "scripts/tutorials/00_sim/spawn_prims.py", line 98, in main
    design_scene()
  File "scripts/tutorials/00_sim/spawn_prims.py", line 59, in design_scene
    cfg_cone.func("/World/Objects/Cone1", cfg_cone, translation=(-1.0, 1.0, 1.0))
  File ".../sim/utils/prims.py", line 715, in wrapper
    prim = func(prim_paths[0], cfg, *args, **kwargs)
  File ".../sim/spawners/shapes/shapes.py", line 231, in spawn_cone
    _spawn_geom_from_prim_type(prim_path, cfg, "Cone", attributes, translation, orientation, stage=stage)
  File ".../sim/spawners/shapes/shapes.py", line 305, in _spawn_geom_from_prim_type
    cfg.visual_material.func(material_path, cfg.visual_material)
  File ".../sim/utils/prims.py", line 715, in wrapper
    prim = func(prim_paths[0], cfg, *args, **kwargs)
  File ".../sim/spawners/materials/visual_materials.py", line 64, in spawn_preview_surface
    shader_prim = CreateShaderPrimFromSdrCommand(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: CreateShaderPrimFromSdrCommand.__init__() got an unexpected keyword argument 'name'

The issue is in source/isaaclab/isaaclab/sim/spawners/materials/visual_materials.py
in the spawn_preview_surface() function. The name="Shader" argument passed to
CreateShaderPrimFromSdrCommand was removed in Omniverse Kit >= 1.13.17:

# Current broken code
shader_prim = CreateShaderPrimFromSdrCommand(
    parent_path=prim_path,
    identifier="UsdPreviewSurface",
    stage_or_context=stage,
    name="Shader",  # ← no longer a valid argument
).do()

# Fix: remove the name argument
shader_prim = CreateShaderPrimFromSdrCommand(
    parent_path=prim_path,
    identifier="UsdPreviewSurface",
    stage_or_context=stage,
).do()

System Info

Additional context

After further debugging, the root cause involves two separate failures:

Fix 1 — Remove deprecated name argument:

# Before (broken on Kit >= 1.13.17)
shader_prim = CreateShaderPrimFromSdrCommand(
    parent_path=prim_path,
    identifier="UsdPreviewSurface",
    stage_or_context=stage,
    name="Shader",
).do()

# After
shader_prim = CreateShaderPrimFromSdrCommand(
    parent_path=prim_path,
    identifier="UsdPreviewSurface",
    stage_or_context=stage,
).do()

Fix 2 — The new API creates the shader prim as UsdPreviewSurface
(not Shader). The hardcoded path lookup must be updated accordingly:

# Before
prim = stage.GetPrimAtPath(f"{prim_path}/Shader")

# After
prim = stage.GetPrimAtPath(f"{prim_path}/UsdPreviewSurface")

Confirmed via debug output:

child path: /World/Objects/Cone1/geometry/material/UsdPreviewSurface, name: UsdPreviewSurface
shader_prim returned: UsdShade.Shader(Usd.Prim(</World/Objects/Cone1/geometry/material/UsdPreviewSurface>))

I have a working fix and am happy to submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions