Problem about get mesh translation value

Hi,
I want to get mesh’s position in IsaacSim
How I can get this translation value?

  • Not XPrim value!
    Isaacsim provide mesh’s translation already,
    I hope to get mesh’s location using python code

Hi @gwangin

The following code snippets can help you to compute the local and world transformations of a prim

import omni.usd
from pxr import Gf
from pxr import Usd, UsdGeom

prim_path = "/PATH_TO_PRIM"

stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath(prim_path)

# compute world-space transform
transform = Gf.Transform()
transform.SetMatrix(UsdGeom.Xformable(prim).ComputeLocalToWorldTransform(Usd.TimeCode.Default()))

# get translation, rotation and scale
translation = transform.GetTranslation()
rotation = transform.GetRotation().GetQuat()
scale = transform.GetScale()

print(translation, rotation, scale)

# compute local-space transform
transform = Gf.Transform()
transform.SetMatrix(UsdGeom.Xformable(prim).GetLocalTransformation())

# get translation, rotation and scale
translation = transform.GetTranslation()
rotation = transform.GetRotation().GetQuat()
scale = transform.GetScale()

print(translation, rotation, scale)

Btw, I think (not completely sure) that the Isaac Sim Core API also allows retrieving the transformations, even if it is not an XFrom but a mesh as in your case. Try it and keep what suits your needs :)

from omni.isaac.core.prims import XFormPrim

prim_path = "/PATH_TO_PRIM"

xform_prim = XFormPrim(prim_path=prim_path)
world_pose = xform_prim.get_world_pose()
local_pose = xform_prim.get_local_pose()

print(world_pose)
print(local_pose)
1 Like

Hi,
Thank you about your kind explaination!
and I also found some method to find mesh translate.
GetAttribute(“xfromOp:translate”).Get()

Thanks,

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