I am using scatter_2d however my objects of interests (here pallets) that are thrown are not collision free and here they collide with the boxes in offline_generation.py. This happens despite using check_for_collisions=True so I am not sure what I should use so objects don’t be spawn like this
Randomize boxes materials and their location on the surface of the given prim
def register_scatter_pallets(prim):
# Calculate the bounds of the prim to create a scatter plane of its size
bb_cache = create_bbox_cache()
bbox3d_gf = bb_cache.ComputeLocalBound(prim)
prim_tf_gf = omni.usd.get_world_transform_matrix(prim)
# Calculate the bounds of the prim
bbox3d_gf.Transform(prim_tf_gf)
range_size = bbox3d_gf.GetRange().GetSize()
# Get the quaterion of the prim in xyzw format from usd
prim_quat_gf = prim_tf_gf.ExtractRotation().GetQuaternion()
prim_quat_xyzw = (prim_quat_gf.GetReal(), *prim_quat_gf.GetImaginary())
# Create a plane on the pallet to scatter the boxes on
plane_scale = (range_size[0] * 5, range_size[1] * 5, 1)
plane_pos_gf = prim_tf_gf.ExtractTranslation() + Gf.Vec3d(0, 0, range_size[2])
plane_rot_euler_deg = quat_to_euler_angles(np.array(prim_quat_xyzw), degrees=True)
scatter_plane = rep.create.plane(
scale=plane_scale, position=plane_pos_gf, rotation=plane_rot_euler_deg, visible=False
)
def scatter_pallets():
pallets2 = rep.create.from_usd(
prefix_with_isaac_asset_server(PALLET_2_URL), semantics=[("class", "Pallet2")], count=20
)
with pallets2:
rep.randomizer.scatter_2d(scatter_plane, check_for_collisions=True)
return pallets2.node
rep.randomizer.register(scatter_pallets)
Here are some of the unrealistic collisions that has happened that I expect it not to happen. Thanks for any direction.
Currently check_for_collisions=True only considers the scattered objects and not their surroundings.
For such cases, I would recommend using Isaac Sim’s API to spawn/move objects and check for their collisions/overlaps with their surroundings as well.
Example of physx api call for checking for overlaps:
I did use the “offline_generation.py” script and just edited the “rep.randomizer.scatter_2d” function to 3d in line 87and created a cube instead of a plane beforehand with
import omni.replicator.core as rep
print("No collision check")
spheres = rep.create.sphere(count=200)
volume_torus = rep.create.torus(scale=10, visible=True)
with spheres:
rep.randomizer.scatter_3d(volume_torus, check_for_collisions=False)
print("Check for collisions")
spheres_2 = rep.create.sphere(count=200)
volume_torus_2 = rep.create.torus(position=(10,10,10), scale=10, visible=True)
with spheres_2:
rep.randomizer.scatter_3d(volume_torus_2, check_for_collisions=True)
Can you check if you got the following error during scatter, you might be giving too many items to randomize in the volume and the algorithm times out:
[Error] [omni.graph.core.plugin] /Replicator/SDGPipeline/OgnScatter3D_02: Assertion raised in compute - Randomization timed out, cannot find a configuration to randomize prim locations and prevent collisions.