The goal is:
- create a plane
- use scatter_2d to scatter pallets into the plane in a collision free fashion
- randomize the camera movement such that it always looks at the average position of pallets
Currently, when I click on preview after clicking on Run button in Isaac Sim interactive, I only see the plane through camera. Also, I am not sure if the units or ordering of x, y, z are correct. I couldn’t find a guide on further detailing of camera movement.
import omni.replicator.core as rep
from datetime import datetime
import omni.usd
import omni.isaac.core.utils.bounds as bounds_utils
import omni.isaac.core.utils.prims as prims_utils
with rep.new_layer():
# Define paths for the character, the props, the environment and the surface where the assets will be scattered in.
PALLET_URL = "omniverse://localhost/NVIDIA/Assets/ArchVis/Industrial/Pallets/Pallet_B1.usd"
plane = rep.create.plane(scale=2000, visible=True, semantics=[("class", "plane")])
print('plane type: ', type(plane))
# bb_cache = bounds_utils.create_bbox_cache()
# combined_range_arr = bounds_utils.compute_combined_aabb(bb_cache, prim_paths=plane)
# min_x, min_y, min_z, max_x, max_y, max_z = combined_range_arr
# print('min_x {}, min_y {}, min_z {}, max_x {}, max_y {}, and max_z {}'.format(
# min_x, min_y, min_z, max_x, max_y, max_z))
# stage = omni.usd.get_context().get_stage()
with plane:
rep.physics.collider()
print('type of plane: ', print(plane))
def scatter_pallets(prim):
pallets = rep.create.from_usd(PALLET_URL, semantics=[('class', 'pallet')], count=5)
with pallets:
rep.physics.collider()
rep.modify.pose(scale=0.001)
rep.randomizer.scatter_2d(surface_prims=plane, check_for_collisions=True)
return pallets
# Register randomization
rep.randomizer.register(scatter_pallets)
# Setup camera and attach it to render product
camera = rep.create.camera(
position=(871, 80, 343),
focus_distance=800,
f_stop=100,
focal_length=40
# focal_length = 24,
# focus_distance = 400,
# f_stop = 0.0
)
distance_light = rep.create.light(rotation=(315,0,0), intensity=3000, light_type="distant")
render_product = rep.create.render_product(camera, resolution=(1024, 1024))
timestamp = datetime.now().strftime("%Y_%m_%d-%I_%M_%S_%p")
# Initialize and attach writer
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(output_dir="/home/mona/Desktop/Isaac_Sim_Dummy_Out/pallet/" + timestamp , rgb=True, bounding_box_2d_tight=True)
writer.attach([render_product])
with rep.trigger.on_frame(num_frames=100):
pallets = rep.randomizer.scatter_pallets(plane)
with camera:
rep.modify.pose(position=rep.distribution.uniform((600, 80, 300), (800, 100, 400)), look_at=pallets)
For example, when manipulating the camera params from the stage, I can see this is a good view:
But I am not sure how it can translate to the scripting and scaling in Isaac Sim.