How do I lock the pose of DynamicCylinder in Python?

I am developing Python standalone application for Isaac Sim and I can lock the pose of generated DynamicCylinder object through following interface:

But how can I do this in Python? This is my Python code that defines DynamicCylinder.

scene.add(
            DynamicCylinder(
                prim_path="/World/contamination/contamination_" + index,
                name="contamination_" + index,
                translation=pos[i],
                orientation=np.array([0.5, 0.5, 0.5, 0.5]),
                radius=radius,
                height=height,
                color=np.array([0, 0, 1])
            )
        )

Hi,
yes you can do that through the standard USD interface using PhysxSchema, something like this:

from pxr import PhysxSchema

        usdPrim = stage.GetPrimAtPath(boxActorPath)
        physxAPI = PhysxSchema.PhysxRigidBodyAPI.Apply(usdPrim)
        physxAPI.CreateLockedPosAxisAttr(7)

See the PhysxSchema documentation:
http://omniverse-docs.s3-website-us-east-1.amazonaws.com/omni_usd_schema_physics/104.2/class_physx_schema_physx_rigid_body_a_p_i.html#ab6cc19deb5ddbd81b5679760b3b016fa

Regards,
Ales

1 Like
from omni.isaac.core.objects import DynamicCylinder
from omni.isaac.core.utils.stage import get_current_stage
from pxr import PhysxSchema

dynamic_cylinder = DynamicCylinder(
    prim_path="/World/contamination/contamination_" + index,
    name="contamination_" + index,
    translation=pos[i],
    orientation=np.array([0.5, 0.5, 0.5, 0.5]),
    radius=radius,
    height=height,
    color=np.array([0, 0, 1])
)
        
stage = get_current_stage()

usdPrim = stage.GetPrimAtPath("/World/contamination/contamination_" + index)
physxAPI = PhysxSchema.PhysxRigidBodyAPI.Apply(usdPrim)
physxAPI.CreateLockedPosAxisAttr(7)

scene.add(dynamic_cylinder )

has solved the problem. Thanks!

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