How to apply force on Rigid Body/Joints using Standalone python scripting

Hello,

I am trying to create a very basic simulation of a point mass where I want to move the mass in a circle of constant radius.

To achieve this, I followed these steps:

  • I created a scene in USD file format using the GUI option.
  • I applied the Physics API (Mass, Force, and Rigid Body) to the sphere (prims) via the GUI.

My question:

I know that I can use the GUI option to set different variable values such as mass, linear velocity, and force. However, I want to set these variables through Python scripting. I couldn’t find the documentation for this. I am attaching the code and USD file for reference.

I hope this helps!

pointMass_path = str(_ROOT_DIR) + "/usd/point_mass/point_mass.usd"

my_world = World(stage_units_in_meters = 1.0,
                 physics_prim_path = "/World/physicsScene")
my_world.scene.add_default_ground_plane()
add_reference_to_stage(usd_path = pointMass_path,
                       prim_path="/World/object1")


my_world.reset()
while 1:
    my_world.step(render=True)

simulation_app.close()

point_mass.usd (8.3 KB)

Hi,
you should be able to use standard USD schema python code to do this. All physics demos are written and python, you can inspect the code. Open Window->Simulation->Physics->Demos, there each demo does have a python snippet code to showcase the feature.
Additionally you can check the doxygen documentation for UsdPhysics:
https://openusd.org/release/api/usd_physics_page_front.html

Or for PhysxSchema:
http://omniverse-docs.s3-website-us-east-1.amazonaws.com/omni_usd_schema_physics/104.2/index.html#purpose_and_scope

In general in python all works the same way as USD as all are USD schemas build on top of USD.

You can also check the omni.physx programmer guide, that does have examples for UsdPhysics, PhysxSchema python usage:
http://omniverse-docs.s3-website-us-east-1.amazonaws.com/omni_physics/104.2/source/extensions/omni.physx/docs/index.html

Regards,
Ales

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