How to automatically make the assets inside Isaac Sim Nucleus SimReady to fix the collision problem?

I have Enterprise Omniverse and Isaac Sim 2023.1.1 and I am using a couple of objects that when I spawn, they collide with each other plus I cannot change their texture since they don’t have the field.

My assumption is that these objects, despite being in Nucleus are not SimReady. Since when I use the certain SimReady assets from NVIDIA I don’t have collision problem and I am able to change their texture/color.

Could you please suggest how to make the assets in Nucleus SimReady hopefully automatically? I am not a 3D artist or computer graphics experts and it’s beyond my level of expertise.

The assets I chose are from

omniverse://localhost/NVIDIA/Assets/DigitalTwin/Assets/Warehouse/

Below, is an example of unpleasant and unrealistic collision (two boxes don’t collide like that)

image

Thank you.

Hi there,

the assets you are using are probably not sim-ready (they have no collisions or physics simulation capabilities yet). You can for example quickly test them by drag and dropping them to stage and pressing play, if the assets are not falling they have no rigid-body simulation enabled. If the assets are falling, they are however not colliding with others they probably have rigid body enabled but no colliders. And if they have collisions, but are not moving, then they probably have colliders but the ribid body simulation disabled.

here is how you can add collision and rigid body simulation capabilities to (non-sim-ready) assets throught he UI:

here is also a short video tutorial on the matter:

here is an example on accessing simready assets through API:

here are code snippets on how you can add this from python using the USD API:

# Iterate descendant prims (including root) and add colliders to mesh or primitive types
def add_colliders(root_prim):
    # Iterate descendant prims and add colliders to mesh or primitive types
    for desc_prim in Usd.PrimRange(root_prim):
        if desc_prim.IsA(UsdGeom.Mesh) or desc_prim.IsA(UsdGeom.Gprim):
            # Add collision properties to the mesh (make sure collision is enabled)
            if not desc_prim.HasAPI(UsdPhysics.CollisionAPI):
                collision_api = UsdPhysics.CollisionAPI.Apply(desc_prim)
            else:
                collision_api = UsdPhysics.CollisionAPI(desc_prim)
            collision_api.CreateCollisionEnabledAttr(True)

            # Add PhysX collision properties to the mesh (e.g. bouncyness)
            if not desc_prim.HasAPI(PhysxSchema.PhysxCollisionAPI):
                physx_collision_api = PhysxSchema.PhysxCollisionAPI.Apply(desc_prim)
            else:
                physx_collision_api = PhysxSchema.PhysxCollisionAPI(desc_prim)
            physx_collision_api.CreateRestOffsetAttr(0.0)

        # Add mesh specific collision properties only to mesh types
        if desc_prim.IsA(UsdGeom.Mesh):
            # Add mesh collision properties to the mesh (e.g. collider aproximation type)
            if not desc_prim.HasAPI(UsdPhysics.MeshCollisionAPI):
                mesh_collision_api = UsdPhysics.MeshCollisionAPI.Apply(desc_prim)
            else:
                mesh_collision_api = UsdPhysics.MeshCollisionAPI(desc_prim)
            mesh_collision_api.CreateApproximationAttr().Set("convexHull")

# Check if prim (or its descendants) has colliders
def has_colliders(root_prim):
    for desc_prim in Usd.PrimRange(root_prim):
        if desc_prim.HasAPI(UsdPhysics.CollisionAPI):
            return True
    return False

# Add dynamics properties to the prim (if mesh or primitive) (rigid body to root + colliders to the meshes)
def add_colliders_and_rigid_body_dynamics(prim):
    # Add colliders to mesh or primitive types of the descendants of the prim (including root)
    add_colliders(prim)

    # Add rigid body dynamics properties to the root only if it has colliders
    if has_colliders(prim):
        if not prim.HasAPI(UsdPhysics.RigidBodyAPI):
            rigid_body_api = UsdPhysics.RigidBodyAPI.Apply(prim)
        else:
            rigid_body_api = UsdPhysics.RigidBodyAPI(prim)
        rigid_body_api.CreateRigidBodyEnabledAttr(True)
    else:
        print(f"Prim '{prim.GetPath()}' has no colliders. Skipping rigid body dynamics properties.")

here is how you can do it with the replicator API:

NOTE: even if an object is simready, if you spawn/teleport them so that they collide, they will overlap eachother, only after starting the simulateion (for at least one step) the collisions will be solved by pushing the objects out of each other. This will also apply force on the objects, so if the simulation continues to run the objects will continue to move until the force is dampened out. In this case you can pause/stop the simulation and set the velocity of the objects to 0.

You can also compute collisions by checking for overlap areas, if the two objects overlap you will get the penetration depth and can apply that distance to move the objects. This can be done without simulation, see here an example using this (search for get_physx_scene_query_interface().overlap_box):

2 Likes