Get Euler angles rotation of a prim

I’m having trouble getting the exact rotation of a prim. I followed the video totorial given in the solution here:

I tried the following:

def decompose_matrix(self, mat: Gf.Matrix4d):
        reversed_ident_mtx = reversed(Gf.Matrix3d())
        translate: Gf.Vec3d = mat.ExtractTranslation()
        scale: Gf.Vec3d = Gf.Vec3d(*(v.GetLength() for v in mat.ExtractRotationMatrix()))

        rotate = Gf.Vec3d(*reversed(mat.ExtractRotation().Decompose(*reversed_ident_mtx)))

        return translate, rotate, scale

 def get_world_transform_xform(self, prim: Usd.Prim) -> typing.Tuple[Gf.Vec3d, Gf.Rotation, Gf.Vec3d]:
        world_transform: Gf.Matrix4d = omni.usd.get_world_transform_matrix(prim)
        decompose_matrix = self.decompose_matrix(world_transform)
        return decompose_matrix

 def get_local_transform_xform(self, prim: Usd.Prim):

        xform = UsdGeom.Xformable(prim)
        local_transform: Gf.Matrix4d = xform.GetLocalTransformation()

        decompose_matrix = self.decompose_matrix(local_transform)
        return decompose_matrix

 def get_global_transform_omni(self, prim):

        xform = UsdGeom.Xformable(prim)
        mtrx = xform.ComputeLocalToWorldTransform(0)
        decompose_matrix = self.decompose_matrix(mtrx)
        return decompose_matrix

the good news is that they all give me the same solution. The bad news is that its not the rotation displayed in the editor:



any input on this would be super helpful. I saw it working perfectly in the office hours video not sure whats wrong on my end. I did notice that in Mati’s editor he had ‘Rotate’ while I have ‘Orient’:

But still its just Euler angles so it shouldnt be different. On my end if I add ‘Rotate’ Only the Orient changes with the rotation of the prim. ‘Rotate’ is always zeros.

my understanding is that Mati’s code snippet and other options you’ve tried are correct when displaying the exact rotation value. however, the GUI might be misleading (?). here’s a simple example with just a plane in Isaac Sim 2023.1.0 hotfix.1:


so, i’ll let the mods/devs chime in and hopefully clarify the difference you were seeing from the code vs GUI. also, i think when you add Rotate attribute to a prim that already has Orient attribute, or vice versa, they became additive to one another. furthermore, one acts independently from the other in the GUI and you won’t necessarily see correlation/ real time update as you change one or the other. but both should contribute to the prim’s rotational attribute

i believe Isaac Sim’s default stage preference is to use Orient. but you could change that behavior through Preferences to whichever that makes more sense:

1 Like

changing the stage pefrences and insuring my transform had rotate (and not orient) solved it. thank you.

1 Like

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