Hi there,
the look_at arguments requires a list of paths in case of multiple prims. In the newer replicator version you can use get_output_prims on the node to access these:
pallets = rep.create.from_usd(PALLET_URL, semantics=[("class", "pallet")], count=10)
pallets_paths = [prim.GetPath() for prim in pallets.get_output_prims()["prims"]]
Here is a fixed script which should work with the shipping of version isaac sim version 2023.1.0:
import os
import omni
import omni.replicator.core as rep
from omni.isaac.core.utils.nucleus import get_assets_root_path
from pxr import Gf, Usd, UsdGeom
PALLET_URL = "/Isaac/Environments/Simple_Warehouse/Props/SM_PaletteA_01.usd"
ENV_URL = "/Isaac/Environments/Simple_Warehouse/full_warehouse.usd"
assets_root_path = get_assets_root_path()
omni.usd.get_context().open_stage(assets_root_path + ENV_URL)
stage = omni.usd.get_context().get_stage()
floor_prims_paths = [prim.GetPath() for prim in stage.Traverse() if "SM_floor" in prim.GetName()]
floor_prims = []
for floor_prim_path in floor_prims_paths:
floor_prims.append(omni.usd.get_prim_at_path(floor_prim_path))
def compute_bbox_with_cache(cache: UsdGeom.BBoxCache, prim: Usd.Prim) -> Gf.Range3d:
bound = cache.ComputeWorldBound(prim)
bound_range = bound.ComputeAlignedBox()
return bound_range
bbcache = UsdGeom.BBoxCache(Usd.TimeCode.Default(), ["default", "render"])
bb = compute_bbox_with_cache(bbcache, floor_prims[0])
max_x, max_y, max_z = bb.GetMax()
min_x_arr = []
min_y_arr = []
min_z_arr = []
max_x_arr = []
max_y_arr = []
max_z_arr = []
for floor_prim in floor_prims:
tmp_bb = compute_bbox_with_cache(bbcache, floor_prim)
tmp_min_x, tmp_min_y, tmp_min_z = tmp_bb.GetMin()
tmp_max_x, tmp_max_y, tmp_max_z = tmp_bb.GetMax()
min_x_arr.append(tmp_min_x)
min_y_arr.append(tmp_min_y)
min_z_arr.append(tmp_min_z)
max_x_arr.append(tmp_max_x)
max_y_arr.append(tmp_max_y)
max_z_arr.append(tmp_max_z)
min_x = min(min_x_arr)
min_y = min(min_y_arr)
min_z = min(min_z_arr)
max_x = max(max_x_arr)
max_y = max(max_y_arr)
max_z = max(max_z_arr)
margin = 3
camera = rep.create.camera()
render_product = rep.create.render_product(camera, resolution=(1024, 1024))
writer = rep.WriterRegistry.get("BasicWriter")
out_dir = os.path.join(os.getcwd(), "_out_scattered_pallets_warehouse")
writer.initialize(output_dir=out_dir, rgb=True, bounding_box_2d_tight=True)
writer.attach([render_product])
with rep.trigger.on_frame(num_frames=50):
pallets = rep.create.from_usd(PALLET_URL, semantics=[("class", "pallet")], count=10)
pallets_paths = [prim.GetPath() for prim in pallets.get_output_prims()["prims"]]
print(f"pallets_paths: {pallets_paths}")
with pallets:
rep.physics.collider()
floor_paths_as_str = [str(path) for path in floor_prims_paths]
rep.randomizer.scatter_2d(surface_prims=floor_paths_as_str, check_for_collisions=True),
with camera:
rep.modify.pose(
position=rep.distribution.uniform((min_x + margin, min_y + margin, 4), (max_x - margin, max_y - margin, 7)),
look_at=pallets_paths,
)