Scatter_2d check_for_collision not working

I am currently testing out the scatter_2d function with the following code:

import omni.replicator.core as rep

import omni.usd

#rep.settings.carb_settings("/omni/replicator/RTSubframes", 10)

with rep.new_layer():

    camera =, 1000, 1000), look_at=(0,0,0))

    render_product = rep.create.render_product(camera, (1024, 1024))
    torus = rep.create.torus(semantics=[('class', 'torus')] , position=(0, -200 , 100),count=3)

    sphere = rep.create.sphere(semantics=[('class', 'sphere')], position=(0, 100, 100),count=3)

    cube = rep.create.cube(semantics=[('class', 'cube')],  position=(100, -200 , 100),count=3 )

    mats = rep.create.material_omnipbr(diffuse=rep.distribution.uniform((0, 0, 0), (1, 1, 1)), count=100)

    plane = rep.create.plane(scale=10, visible=True)

    def get_shapes():
        with rep.utils.sequential():
            shapes = rep.get.prims(semantics=[('class', 'cube'), ('class', 'sphere'), ('class', 'torus')])
            # with torus:
            #     rep.randomizer.scatter_2d(surface_prims=plane, offset=50, check_for_collisions=True)
            # with cube:
            #     rep.randomizer.scatter_2d(surface_prims=plane, offset=200, check_for_collisions=True)
            # with sphere:
            #     rep.randomizer.scatter_2d(surface_prims=plane, offset=125, check_for_collisions=True)
            with shapes:
                # rep.modify.pose(
                #     position=rep.distribution.uniform((-200, 100, -200), (200, 500, 200)),
                #     scale=rep.distribution.uniform(0.1, 2))
                rep.randomizer.scatter_2d(surface_prims=plane,  check_for_collisions=True)
                rep.randomizer.color(colors=rep.distribution.uniform((0, 0, 0), (1, 1, 1)))

            return shapes.node


    with rep.trigger.on_frame(num_frames=10,rt_subframes=10):
        # with camera:
        #     rep.modify.pose(position=rep.distribution.uniform((-500, 200, -500), (500, 500, 500)), look_at=(0,0,0))

    # Initialize and attach writer
    writer = rep.WriterRegistry.get("BasicWriter")

    writer.initialize( output_dir="D:/omniverse/output", rgb=True,   instance_segmentation=True,
                       colorize_instance_segmentation=False, instance_id_segmentation=True,



However, the shapes generated often collide as shown in an example below:

I have seen previous topics on the post including the one using sequential as well as the post with replacement python files. I have tried replacing the python files although I am not sure whether the proper files were replaced given the difference in pathing on windows systems.

Also, is there a way to ensure a minimum distance between generated objects when using scatter_2d?

Welcome to the forums, Frederick.

Which version of replicator are you using? I’ve attached some sample code here that works well for me. I just changed the last line of it to:

    import asyncio
    asyncio.ensure_future(rep.orchestrator.step_async()) (3.2 KB)

I’m on Omniverse Code 2022.3.1 and Replicator 1.6.3
I have tried running your code and still get overlaps like this:

Ah … yes, that is an older version of the scatter node. It’s fixed in the newer one. Let me see what I can do, will get back to you soon.

1 Like

OK - I checked in and a new version of code with a new version of replicator is supposed to be out today (if not another day this week). Can you wait for that?

1 Like

Yup thanks for the help!