Rep.randomizer.instantiate making duplicate objects

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])

Hello @jonathan.meitzler! I’ve shared your post with the dev team for further assistance.

Hi @jonathan.meitzler , may I know which version of replicator you are on? I just tested it on omni.replicator.core-1.6.4 seems this problem is solved.

Yeah I was using an older version, 2022.2.0 to be exact. The version after that ran really slow but the latest version, 2022.3.1 seems to be more optimized and I didn’t have any problems with generation.

Thanks! So this is no longer a problem right?

This specifically, no. Although I’ve found another problem where the bottles that show up don’t have any classes attached to them. I’m using pre existing usd’s with their own respective classes, but they don’t carry over into the generations. Is there a way to fix this? Do I have to put them all under one semantic?

hmm weird. instantiate should support semantic labels. We will inspect and get back to you.

@jonathan.meitzler I just tried on 2022.3.1 and I am able to get the semantic labels from the prim. It should be on the prim Cached0_Prim_pi. Can you double check on that?