I’m trying to generate a scene with bottles being randomly generated in an open space by taking them from a directory, however I’ve run into a problem. The items aren’t moving around but are still rotating, and they’re all the same item even though I set with_replacements to false. Why is this happening? Here’s the code and an example of what I’m getting.
import omni.replicator.core as rep
with rep.new_layer():
camera = rep.create.camera(position=(0, 0, 1300), focal_length = 18.14756)
render_product = rep.create.render_product(camera, (1920, 1200))
bottles = '/home/ubuntu/Documents/AIM/Bottles/USD/middle'
theCone = rep.create.cone(semantics=[('class', 'cone')], position=(0, 0, -201), rotation=(90,0,0), scale=(21.4, 29.9, 12), visible=False)
def dome_light():
dome = rep.create.light(
light_type="Dome",
rotation=(270,0,0),
texture=rep.distribution.choice([
'/home/ubuntu/Documents/AIM/EXR/belfast_sunset_4k.hdr',
'/home/ubuntu/Documents/AIM/EXR/belfast_sunset_puresky_4k.hdr',
'/home/ubuntu/Documents/AIM/EXR/castel_st_angelo_roof_4k.hdr',
'/home/ubuntu/Documents/AIM/EXR/clarens_midday_4k.hdr',
'/home/ubuntu/Documents/AIM/EXR/garden_nook_4k.hdr',
'/home/ubuntu/Documents/AIM/EXR/golf_course_sunrise_4k.hdr',
'/home/ubuntu/Documents/AIM/EXR/lythwood_field_4k.hdr',
'/home/ubuntu/Documents/AIM/EXR/noon_grass_4k.hdr',
'/home/ubuntu/Documents/AIM/EXR/pretville_cinema_4k.hdr',
'/home/ubuntu/Documents/AIM/EXR/rainforest_trail_4k.hdr',
'/home/ubuntu/Documents/AIM/EXR/rustig_koppie_puresky_4k.hdr',
'/home/ubuntu/Documents/AIM/EXR/snowy_field_4k.hdr',
'/home/ubuntu/Documents/AIM/EXR/sunflowers_4k.hdr',
'/home/ubuntu/Documents/AIM/EXR/wide_street_01_4k.hdr'
])
)
return dome.node
rep.randomizer.register(dome_light)
def distant_light():
sun = rep.create.light(
light_type = "Distant",
position = rep.distribution.uniform((-3000, -3000, -3000), (3000, 3000, 3000)),
intensity = rep.distribution.uniform(3000, 7000),
look_at = (0, 0, 0)
)
return sun.node
rep.randomizer.register(distant_light)
def move_shapes(size=7):
instances = rep.randomizer.instantiate(
rep.utils.get_usd_files(bottles), with_replacements = False, size=size, mode='point_instance')
with instances:
rep.modify.pose(rotation = rep.distribution.uniform((0, 0, 0), (360, 360, 360)))
rep.randomizer.scatter_3d(volume_prims=theCone, check_for_collisions=True)
return instances.node
rep.randomizer.register(move_shapes)
with rep.trigger.on_time(interval=1, num=11):
rep.randomizer.move_shapes()
rep.randomizer.dome_light()
rep.randomizer.distant_light()
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(
output_dir="BottleInstanceGrid",
rgb=True,
bounding_box_2d_loose=True,
instance_segmentation=True
)
writer.attach([render_product])