Hi,
If I want to create multiple objects without gravity such as the link (https://www.youtube.com/watch?v=ZUq9i5PP2A8&t=128s) until grasping from gripper. How to set in python environment?
Thank you!
Hi,
If I want to create multiple objects without gravity such as the link (https://www.youtube.com/watch?v=ZUq9i5PP2A8&t=128s) until grasping from gripper. How to set in python environment?
Thank you!
Hi,
you can disable gravity and increase linear and angular damping to get the zero gravity behavior.
In the property window of a rigid body you can change those, from python code you need change attributes on a PhysxRigidBodyAPI, something like this:
from pxr import PhysxSchema
physxAPI = PhysxSchema.PhysxRigidBodyAPI.Apply(cubePrim)
physxAPI.CreateDisableGravityAttr(True)
physxAPI.GetLinearDampingAttr().Set(0.0)
physxAPI.GetAngularDampingAttr().Set(0.0)
Regards,
Ales
Hi, @AlesBorovicka,
I tried the code you mentioned.
As you can see in the video, the object fell down even though the linear and angular damping were set to more than 0.0 with disabled gravity.
Do you have any idea?
Thank you.
stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath("/World/Object/object_1")
physxAPI = PhysxSchema.PhysxRigidBodyAPI.Apply(prim)
physxAPI.CreateDisableGravityAttr(True)
physxAPI.GetLinearDampingAttr().Set(1000.0)
physxAPI.GetAngularDampingAttr().Set(1000.0)
Just to be sure and there is a RigidBodyAPI applied on the prim path:
“/World/Object/object_1”?
I did with UsdPhysics.RigidBodyAPI.Apply(prim)
, but same problem.
Is it right approach?
Thanks.
No, not really, you need to know where the rigid body API is, you cant just apply it. If that object moves, there is somewhere in the hierarchy rigid body API, you should check in the editor. In stage window you can filter by rigid bodies. Once you find where your rigid body is in that asset, there you can add/modify the PhysX additional properties. PhysxSchema.RigidBodyAPI contains additional PhysX SDK parameters, like disable gravity or damping, it has to extend the already existing rigid body API. So applying that in a script is not really a solution, most likely now you see in the log/console error about nested rigid bodies. I suspect your rigid body is actually applied to he object prim? Hence the parent?
Just first try to adjust those parameters in the UI, select the rigid body and in the property window change the parameters, they are present. Then try with a script.
It works! Thanks you @AlesBorovicka
That is most likely because the rigid body is asleep, you should wake it up after changing those parameters back.
Try something like this after setting the gravity and damping back:
from omni.physx import get_physx_simulation_interface
from pxr import PhysicsSchemaTools, UsdUtils
stage_id = UsdUtils.StageCache.Get().GetId(stage).ToLongInt()
rbo_encoded = PhysicsSchemaTools.sdfPathToInt(prim.GetPrimPath())
get_physx_simulation_interface().wake_up(stage_id, rbo_encoded)
Regards,
Ales
Thank you for replying. @AlesBorovicka
Weirdly, step 2 -> step 1
works, but step 2 -> step 1 -> step 2
or step 1 -> step 2
does not work, even though I tried using the tips you mentioned to wake it up.
Regards,
Jon
Not sure then what the problem could be, copying your script and executing seems to work even without the sleeping thing, see my video:
Just calling those steps from 1 to 2 seems to do exactly the expected thing.
Regards,
Ales
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.