How to disable collision between jointed bodies?

Hello, I’m having trouble with the “Collision Enabled” checkbox. In this video, I’m trying to disable the collision between the button and the box, but they still keep colliding. Could you help me understand how to properly disable the collision?

This is the USD file:
task_board_flatten.zip (3.2 MB)

By the way, I have already increased the lower and upper limits.

Hi,

First of all, sorry about not answering this sooner.

The issue you have is that for the internal collision to be disabled, the joints must point directly to the prim with the collider (rather than a parent of the prim). Since in your case, the body you want to avoid collision with is actually a collection of multiple colliders, one solution is to merge those colliders into a single collider, and then attach the joint to the merged collider prim. This can easily be achieved using the MeshMergeCollision API, so you won’t have to update the model. I’ve attached an updated version of your scene that shows how this can be accomplished:
task_board_flatten_meshmerge.zip (2.7 MB)

Alternatively, you can explicitly disable collision between the box colliders and the various buttons by using Pair Filtering or CollisionGroups. I’ve also attached an example of how to accomplish this in your scene:
task_board_flatten_collision_groups.zip (2.7 MB)

Best regards,

Soren Moller

1 Like

Hi,

Could you give an example of using MeshMergeCollision API in python script?

Thanks!

Here’s an example:

from pxr import Usd, UsdGeom, UsdPhysics, Gf, PhysxSchema
import omni.usd

# Create a stage
omni.usd.get_context().new_stage()
stage = omni.usd.get_context().get_stage()

# Define the root Xform (transformable object)
rootxform = UsdGeom.Xform.Define(stage, "/World")

rigidBodyXform = UsdGeom.Xform.Define(stage, "/World/rigidBody")
UsdPhysics.RigidBodyAPI.Apply(rigidBodyXform.GetPrim())

# Apply also the collision definitions here
UsdPhysics.CollisionAPI.Apply(rigidBodyXform.GetPrim())
collisionMeshAPI = UsdPhysics.MeshCollisionAPI.Apply(rigidBodyXform.GetPrim())
collisionMeshAPI.GetApproximationAttr().Set(UsdPhysics.Tokens.convexHull)

# Define shared mesh points
halfSize = 0.5
points = [
    Gf.Vec3f(halfSize, -halfSize, -halfSize),
    Gf.Vec3f(halfSize, halfSize, -halfSize),
    Gf.Vec3f(halfSize, halfSize, halfSize),
    Gf.Vec3f(halfSize, -halfSize, halfSize),
    Gf.Vec3f(-halfSize, -halfSize, -halfSize),
    Gf.Vec3f(-halfSize, halfSize, -halfSize),
    Gf.Vec3f(-halfSize, halfSize, halfSize),
    Gf.Vec3f(-halfSize, -halfSize, halfSize),
]

normals = [
    Gf.Vec3f(1, 0, 0),
    Gf.Vec3f(1, 0, 0),
    Gf.Vec3f(1, 0, 0),
    Gf.Vec3f(1, 0, 0),
    Gf.Vec3f(-1, 0, 0),
    Gf.Vec3f(-1, 0, 0),
    Gf.Vec3f(-1, 0, 0),
    Gf.Vec3f(-1, 0, 0),
]

indices = [
    0, 1, 2, 3, 
    1, 5, 6, 2, 
    3, 2, 6, 7, 
    0, 3, 7, 4,
    1, 0, 4, 5, 
    5, 4, 7, 6
]

vertexCounts = [4, 4, 4, 4, 4, 4]

for i in range(3):
    meshPath = "/World/rigidBody/mesh" + str(i)
    mesh = UsdGeom.Mesh.Define(stage, meshPath)
    mesh.CreateFaceVertexCountsAttr().Set(vertexCounts)
    mesh.CreateFaceVertexIndicesAttr().Set(indices)
    mesh.CreatePointsAttr().Set(points)
    mesh.CreateDoubleSidedAttr().Set(False)
    mesh.CreateNormalsAttr().Set(normals)

    if i == 1:
        mesh.AddTranslateOp().Set(Gf.Vec3f(1.0 * i, 0.0, 1.0))
    else:
        mesh.AddTranslateOp().Set(Gf.Vec3f(1.0 * i, 0.0, 0.0))

# Now setup the mesh merging to include mesh 0 and mesh 2, excluding mesh 1
meshMergeCollision = PhysxSchema.PhysxMeshMergeCollisionAPI.Apply(rigidBodyXform.GetPrim())
meshMergeCollection = meshMergeCollision.GetCollisionMeshesCollectionAPI()
meshMergeCollection.GetIncludesRel().AddTarget("/World/rigidBody")    
meshMergeCollection.GetExcludesRel().AddTarget("/World/rigidBody/mesh1")

It’s very helpful! Thank you very much!

1 Like

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