Add rigidbody with python no property disable gravity RAW USD properties

Hello,

In my simulation I add a rigid body to a Xform with python code (UsdPhysics.RigidBodyAPI.Apply(prim)). The next step is to disable the gravity for that specific rigid body.

I know that you can get and set properties/attributes of a prim and also that you have a function to get all the properties of a prim. When I get all the properties I don’t see the property disable gravity. I investigated further and I found out the you can only get the RAW USD properties of a prim.

I also found out that when you add a RigidBody with the GUI it adds the disable gravity to the RAW USD properties but this doesn’t happen when you do it with python code.

So my question is now why is disable gravity not a RAW USD property when added with python code and can I still set the value of disable gravity to True with python code when it is not a RAW USD property?

Thanks in advance

Note: It adds some of the properties from the Rigid body but not all (see pictures). But when I press the checkbox of disable gravity in the GUI of Isaac Sim, it adds all the properties to the RAW USD properties tab.

I would like to understand this as well.

Hi @nickbakker40 and @nickbakker40

In order to add the rigid body schema to get and set values from Python code you need also to call the PhysxSchema.PhysxRigidBodyAPI.Apply(prim) function.

Example (assuming that the "/World/Xform" exists):

import omni.usd
from pxr import UsdPhysics, PhysxSchema

stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath("/World/Xform")

# apply rigid body API and schema
physicsAPI = UsdPhysics.RigidBodyAPI.Apply(prim)
PhysxSchema.PhysxRigidBodyAPI.Apply(prim)

attr = prim.GetAttribute("physxRigidBody:disableGravity")
print(attr)

The kit command AddPhysicsComponentCommand (called via Add > Physics > Rigid Body context menu) apply those steps

import omni
import omni.usd

stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath("/World/Xform")

# apply rigid body API and schema
omni.kit.commands.execute("AddPhysicsComponentCommand",
                          usd_prim=prim,
                          component="PhysicsRigidBodyAPI")

attr = prim.GetAttribute("physxRigidBody:disableGravity")
print(attr)
2 Likes

Yes, that is correct. The UsdPhysics schema contains just a very small subset of attributes. Pretty much the most common one. All the additional parameters are defined through PhysxSchemas, so you apply additional API to extend the parameters.
You can check the schema documentation:
http://omniverse-docs.s3-website-us-east-1.amazonaws.com/omni_usd_schema_physics/105.0/index.html

Regards,
Ales

1 Like

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