Testing Scatter_2D collision=True in both Omniverse Code and Omniverse Isaac Sim Script Editor in Python

I am trying to test the functionality of scatter_2D and when I use Omniverse Code, scatters are not collision free. Does check_for_collison=True work in Omniverse Code? I even added collider() to plane but it didn’t work.

As you see scattered pallets dived into the inside of the plane.

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=25, visible=True, semantics=[("class", "plane")])
    with plane:
    print('type of plane: ', print(plane))

    def scatter_pallets():
        pallets = rep.create.from_usd(PALLET_URL, semantics=[('class', 'pallet')], count=10)
        with pallets:
            rep.randomizer.scatter_2d(surface_prims=plane, check_for_collisions=True)
        return pallets

    # Register randomization


    # Setup camera and attach it to render product
    camera = rep.create.camera(
    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)

    with rep.trigger.on_frame(num_frames=100):

        pallets = rep.randomizer.scatter_pallets()
        with camera:
            rep.modify.pose(position=rep.distribution.uniform((-1000, 200, 1500), (1000, 400, 2000)), look_at=pallets)

When I try the code in Isaac Sim, dimensions are messed up hence I cannot test it. If you can tell me how I can can test this code in Isaac Sim Script Editor it would be really great.

Currently, check_for_collisiononly checks for collisions between the objects being scattered, it does not consider the environment (e.g. the plane in this case).

1 Like

Hi @ahaidu thanks for your response.

Is there any other way I could use in order to avoid the collision with floor?

You can write a custom scatterer using usd or isaac sim api, similar to this answer: Scatter_2d is not guaranting collision free scatter - #3 by ahaidu

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.