How do I add a Contact Sensor to a drone that meets the requirements of Pegasus Sim? This might seem like a silly or obvious question to ask, but what it boils down to is that the requirements of Pegasus Sim and Contact Sensors appear to be incompatible, or at least I can’t figure out the exact configuration that will allow them to work together.
I’ve tried to thoroughly document the problem, and what solutions I’ve already tried that haven’t worked. Apologies in advance for over-explaining everything, but this is a problem where the context and details are key.
I’m using:
- Pegasus Sim 5.1.0
- Isaac Sim 5.1.0
- Ubuntu 24.04
Background
To fully understand the problem, I have to explain the requirements of Pegasus Sim and Contact Sensors/Isaac Sim
Note: Where I list the APIs connected to prims, I’ve shown only the obvious/relevant ones. For example, when you add a RigidBody property to a prim, you actually get both PhysicsRigidBodyAPI and PhysxRigidBodyAPI, so I’m only going to show the first of these rather than both all the time.
Pegasus Sim Requirements
Pegasus Sim is hard-coded to require a prim hierarchy that looks like this (using the default Iris drone as an example):
vehicle (defaultPrim) | Xform
body | Xform w/ RigidBodyAPI, MassAPI
body | Mesh w/ ColliderAPI
rotor1 | Xform
iris_prop_ccw | Mesh w ColliderAPI
joint0 | PhysicsRevoluteJoint
...
rotor3 | Xform
iris_prop_cw | Mesh w ColliderAPI
joint3 | PhysicsRevoluteJoint
With the following requirements:
bodyMUST be directly belowvehicle. Isaac Sim will otherwise think thebodyXform is invalidbodyMUST be an Xform, you can’t replace it with a mesh that has the rigid body, mass and collider APIs
Contact Sensor / Isaac Sim Requirements
Reading through the documentation around Contact Sensors in Isaac Sim 5.1.0 and the various related forum posts, I have determined that Contact Sensors require the following prim hierarchy:
collision_mesh | Mesh w/ RigidBodyAPI, ColliderAPI, ContactReporterAPI
Contact Sensor | Contact Sensor
With the following requirements:
- A
Contact Sensorcan only be added to a prim that has aRigidBodyANDColliderAPI - The
Contact Sensoralso requires that the parent prim has aContactReporterAPI, but the option for adding it doesn’t even appear unless the mesh already has theRigidBodyandMassAPIs - A parent and child prim cannot both have
RigidBodyAPIs, so you cannot place this collision mesh anywhere underbody. Isaac Sim will throw all sorts of physics related warnings and errors.
Problem
Because of the requirements stated above, you can’t nest the collision mesh and it’s Contact Sensor anywhere below the body Xform, and you can’t modify the placement or configuration of the body Xform either. This limits you to putting it alongside body somehow.
If you start by just putting it at the same nested level, you get a hierarchy that looks like:
vehicle (defaultPrim) | Xform
body | Xform w/ RigidBodyAPI, MassAPI
body | Mesh ColliderAPI
collision_mesh | Mesh w/ RigidBodyAPI, ColliderAPI, ContactReporterAPI
Contact Sensor | Contact Sensor
...rotors etc ....
However now you quickly start running into problems…
If you DON’T remove the ColliderAPI from the body mesh, then your drone and the collision_mesh will fly apart as soon as the simulation starts:
If you DO remove the ColliderAPI from body, the collision_mesh still doesn’t stay part of the drone, even though its nested under the same root prim:
If you instead use a FixedJoint to connect the collision_mesh prim to the body Xform or mesh, the whole drone now becomes immobile, won’t take off, and Ardupilot will throw a “loss of thrust” error. This problem has already been documented on the forum (Robot sliding: wheel has been spinning, but the robot not move…)
Any minor variation of what I’ve described above leads to the same outcomes - either the drone is immobilized or the two meshes aren’t connected.
So, with all of that said and done, what is the solution to this problem? How can I attach a Contact Sensor to this drone in a way that doesn’t break it?