How to apply ForceFieldAPI in Isaac-sim-5.1.0

Isaac Sim Version

5.1.0

Operating System

Windows 11

GPU Information

  • Model: RTX 5090
  • Driver Version:

Detailed Description

As I known, the old forcefield API has been superseded by the new API schema named PhysxForceFieldAPI.

I have seen https://forums.developer.nvidia.com/t/force-filed-extension-removed/345686, but I still cannot find where the API is.

I only found it in USDRT, but I can’t make it work.

I tried to apply it with python:

import omni.usd
from usdrt import Gf, Sdf, Usd, ForceFieldSchema

ctx = omni.usd.get_context()
rtstage = Usd.Stage.Attach(ctx.get_stage_id())
path = "/World/WindField"

omni.kit.commands.execute('CreatePrim',
    prim_path=path,
    prim_type='Xform',
    select_new_prim=True)

wind_xform = rtstage.GetPrimAtPath(path)
force_field_api = ForceFieldSchema.PhysxForceFieldAPI(wind_xform, "wind_field")
wind_field_api = ForceFieldSchema.PhysxForceFieldWindAPI(wind_xform,"wind_field")
# Also tried 
#force_field_api = ForceFieldSchema.PhysxForceFieldAPI.Apply(wind_xform, "wind_field")
print(force_field_api)

And I got :

PhysxForceFieldAPI(invalid)

The “WindField” xform in Isaac-sim still not having the API.

I also check the “Edit API Schema”, and didn’t see any ForceFieldAPI.

I wonder how to apply the ForceFieldAPI correctly.

Thanks for reporting this. I don’t see anything wrong with your usage. Seems the USDRT Physics Schema APIs are not valid. We will look into this.

Hi @YC-Lin , while we’re looking into a fix in USDRT, can you check if you can use the PhysxForceAPI from PhysxSchema in standard USD stage, here’s the example:

from omni.isaac.kit import SimulationApp
simulation_app = SimulationApp({"headless": False})

import omni.usd
from pxr import UsdPhysics, PhysxSchema

ctx = omni.usd.get_context()
stage = ctx.get_stage()
path = "/World/WindField"

# Create the prim using USD stage (not USDRT)
omni.kit.commands.execute('CreatePrim',
    prim_path=path,
    prim_type='Xform',
    select_new_prim=True)

# Get the prim from the USD stage
wind_xform = stage.GetPrimAtPath(path)

# Apply the API using standard USD (not USDRT)
force_api = PhysxSchema.PhysxForceAPI.Apply(wind_xform)
force_api.CreateForceAttr().Set((10.0, 0.0, 0.0))  # Example force vector

print(force_api)  # Should be valid now

@PeterNV Thanks for the reply! Using your example, I can correctly apply the API.

PhysxSchema.PhysxForceAPI(Usd.Prim(</World/WindField>))

I’m looking forward to any fix update.

Just to highlight, I need “ForceFieldAPI” instead of “ForceAPI”.

Also, I wonder if it is possible to use ForceFieldAPI in standard USD stage.

Thanks again for your help!

I wonder if it is possible to use ForceFieldAPI in standard USD stage.

No, there’s no ForceFieldAPI in standard USD stage.

I need “ForceFieldAPI” instead of “ForceAPI”.

The USDRT schema is outdated and we need to update it to match the USD schema, so I think ForceFieldAPI won’t be available anymore. Any specific reason you cannot migrate to ForceAPI?

I see. Thanks for the clarification.

Because I don’t just need ForceFieldAPI, my main goal is to use the Drag and Wind force field features. Can these still be used in versions after 5.0? Or are there any alternative solutions?