When I’m using issacsim, first I add an object, then I apply the rigid body and collision properties to it.After clicking the play button, the only thing that represents the object’s attitude property is orient in the property. However i see the rotate in the property when i have not press the play button.But I need to press the play button and would like to get the Euler angles directly, e.g., like rotate:xyz through script via script editor . How can I do this?
@gaozhao22 take a look at the matrix decomposition by @mati-nvidia where he was able to extrapolate transform, rotation (in Euler), and scale:
# SPDX-License-Identifier: Apache-2.0
from pxr import Gf, UsdGeom, Usd
import omni.usd
def decompose_matrix(mat: Gf.Matrix4d):
reversed_ident_mtx = reversed(Gf.Matrix3d())
translate = mat.ExtractTranslation()
scale = Gf.Vec3d(*(v.GetLength() for v in mat.ExtractRotationMatrix()))
#must remove scaling from mtx before calculating rotations
mat.Orthonormalize()
#without reversed this seems to return angles in ZYX order
rotate = Gf.Vec3d(*reversed(mat.ExtractRotation().Decompose(*reversed_ident_mtx)))
return translate, rotate, scale
stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath("/World/Cube")
xform = UsdGeom.Xformable(prim)
local_transformation: Gf.Matrix4d = xform.GetLocalTransformation()
This file has been truncated. show original
you can watch his breakdown as well in a VOD (since the snippet showed two ways to get rotations):
regarding the orient vs rotation in more detail:
Hi @christof.schuetzenhoefer -
The orient attribute and rotateXYZ attribute are indeed different ways of representing rotations, and they use different formats.
The orient attribute uses quaternions to represent rotations. Quaternions are a type of complex number that can be used to represent rotations in 3D space. They have four components: one real component and three imaginary components. Quaternions are often used in 3D graphics and physics simulations because they can represent rotations…
I am sure there are other ways to get the information you are looking for, so i’ll let others chime in 🙂
2 Likes