Hello,
I tried to follow the example with importing existing USD Files and give them materials. The xforms and parts are created but without material and they behave not really realistic in physical way. They are just flying around, some in a circular path, some in z direction, but none of them collide with my collider plane, so there is something wrong I guess. I also get thousand on thousand lines of error messages if I run the replicator. I will paste a small part of it and my code below.
Code:
import omni.replicator.core as rep
import omni.kit.viewport.utility as vp_utils
from omni.isaac.core.utils.stage import add_reference_to_stage
from omni.isaac.core.utils.prims import create_prim, delete_prim, get_prim_at_path
from pxr import UsdShade, Gf, Sdf, Usd, UsdGeom
base_path ="omniverse://127.0.0.1/BinPicking/BinPicking/"
# Define paths for the character, the props, the environment and the surface where the assets will be scattered in.
PROPS = base_path + "bolzen.usd"
ENVS = ''
#Materialien importieren
Materials = base_path + "materials.usd"
mat_prim_path = "/World/materials"
add_reference_to_stage(usd_path=Materials, prim_path=mat_prim_path)
#Set materials
mat = get_prim_at_path(mat_prim_path)
materials_list = []
for n in Usd.PrimRange(mat):
if n.GetTypeName() == 'Material':
materials_list.append(n.GetPrimPath())
rep.settings.set_stage_meters_per_unit(1)
rep.settings.set_stage_up_axis(up_axis="z")
with rep.new_layer():
# Define randomizer function for Base assets. This randomization includes placement and rotation of the assets on the surface.
def env_props(size=50):
# Define paths for the character, the props, the environment and the surface where the assets will be scattered in.
instances = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS, recursive=True), size=size, mode='scene_instance')
with instances:
rep.modify.pose(
position=rep.distribution.uniform((-0.5, -0.5, 0.2), (0.5, 0.5, 0.3)),
rotation=rep.distribution.uniform((0,-180, 0), (0, 180, 0)),
scale = 1
)
rep.physics.rigid_body()
rep.randomizer.materials(materials=materials_list)
return instances.node
# Register randomization
rep.randomizer.register(env_props)
# Setup the static elements
surface = rep.create.plane(
position = (0,0,0),
scale = 200,
rotation = (0,0,0)
)
with surface:
rep.physics.collider()
# Setup camera and attach it to render product
camera = rep.create.camera(
look_at=surface,
position=(2,2,1)
)
render_product = rep.create.render_product(camera, resolution=(1024, 1024))
#Set Viewport
cam = "/Replicator/Camera_Xform/Camera"
viewport_window = vp_utils.get_active_viewport_window()
viewport_window.viewport_api.set_active_camera(cam)
# sphere lights for extra randomization
def sphere_lights(num):
lights = rep.create.light(
light_type="Sphere",
temperature=rep.distribution.normal(6500, 500),
intensity=rep.distribution.normal(35000, 5000),
position=rep.distribution.uniform((-300, -300, -300), (300, 300, 300)),
scale=rep.distribution.uniform(50, 100),
count=num
)
return lights.node
rep.randomizer.register(sphere_lights)
# trigger on time
with rep.trigger.on_time(interval= 8, num=1):
rep.randomizer.env_props(10)
rep.randomizer.sphere_lights(10)
#rep.randomizer.materials(materials=materials_list)
# Initialize and attach writer
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize( output_dir="_output_physics10", rgb=True, bounding_box_2d_tight=True)
writer.attach([render_product])
Error Messages:
2023-02-22 13:02:55 [1,793,786ms] [Error] [omni.usd] Runtime Error: in _SetValueImpl at line 6068 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usd\stage.cpp -- Cannot set attribute value. Failed to create attribute spec </__Master_3/part.xformOp:translate> in layer @anon:000002927518CB00:World3.usd@
2023-02-22 13:02:55 [1,793,786ms] [Warning] [omni.usd] Coding Error: in _ValidateEditPrim at line 1279 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usd\stage.cpp -- Cannot create property spec at path </__Master_3/part>; authoring to an instancing master is not allowed.
2023-02-22 13:02:55 [1,793,786ms] [Error] [omni.usd] Runtime Error: in _SetValueImpl at line 6068 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usd\stage.cpp -- Cannot set attribute value. Failed to create attribute spec </__Master_3/part.xformOp:orient> in layer @anon:000002927518CB00:World3.usd@
2023-02-22 13:02:55 [1,793,786ms] [Warning] [omni.usd] Coding Error: in _ValidateEditPrim at line 1279 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usd\stage.cpp -- Cannot create property spec at path </__Master_3/part>; authoring to an instancing master is not allowed.
2023-02-22 13:02:55 [1,793,786ms] [Error] [omni.usd] Runtime Error: in _SetValueImpl at line 6068 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usd\stage.cpp -- Cannot set attribute value. Failed to create attribute spec </__Master_3/part.physics:velocity> in layer @anon:000002927518CB00:World3.usd@
2023-02-22 13:02:55 [1,793,786ms] [Warning] [omni.usd] Coding Error: in _ValidateEditPrim at line 1279 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usd\stage.cpp -- Cannot create property spec at path </__Master_3/part>; authoring to an instancing master is not allowed.
2023-02-22 13:02:55 [1,793,786ms] [Error] [omni.usd] Runtime Error: in _SetValueImpl at line 6068 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usd\stage.cpp -- Cannot set attribute value. Failed to create attribute spec </__Master_3/part.physics:angularVelocity> in layer @anon:000002927518CB00:World3.usd@
2023-02-22 13:02:55 [1,793,806ms] [Warning] [omni.usd] Coding Error: in _ValidateEditPrim at line 1279 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usd\stage.cpp -- Cannot create property spec at path </__Master_2/part>; authoring to an instancing master is not allowed.
2023-02-22 13:02:55 [1,793,806ms] [Warning] [omni.usd] Coding Error: in _ValidateEditPrim at line 1279 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usd\stage.cpp -- Cannot create property spec at path </__Master_2/part>; authoring to an instancing master is not allowed.
2023-02-22 13:02:55 [1,793,806ms] [Error] [omni.usd] Runtime Error: in _SetValueImpl at line 6068 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usd\stage.cpp -- Cannot set attribute value. Failed to create attribute spec </__Master_2/part.xformOpOrder> in layer @anon:000002927518CB00:World3.usd@
2023-02-22 13:02:55 [1,793,806ms] [Warning] [omni.usd] Coding Error: in _ValidateEditPrim at line 1279 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usd\stage.cpp -- Cannot create property spec at path </__Master_2/part>; authoring to an instancing master is not allowed.
2023-02-22 13:02:55 [1,793,806ms] [Warning] [omni.usd] Coding Error: in AddXformOp at line 223 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usdGeom\xformable.cpp -- Unable to add xform op of type TypeTransform and precision PrecisionDouble on prim at path </__Master_2/part>. opSuffix=, isInverseOp=0
2023-02-22 13:02:55 [1,793,806ms] [Warning] [omni.usd] Coding Error: in _ValidateEditPrim at line 1279 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usd\stage.cpp -- Cannot create property spec at path </__Master_2/part>; authoring to an instancing master is not allowed.
2023-02-22 13:02:55 [1,793,806ms] [Error] [omni.usd] Runtime Error: in _SetValueImpl at line 6068 of C:\b\w\ca6c508eae419cf8\USD\pxr\usd\usd\stage.cpp -- Cannot set attribute value. Failed to create attribute spec </__Master_2/part.physics:velocity> in layer @anon:000002927518CB00:World3.usd@