Skip to content

Commit c5621a6

Browse files
author
nuofan
committed
fixed a bug for euler angle transform in mjcf
1 parent 1c40142 commit c5621a6

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Add-IN/ACDC4Robot/core/math_operation.py

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def matrix3d_2_euler_xyz(matrix: adsk.core.Matrix3D):
6666
[x, y, z, roll, pitch, yaw]
6767
This euler angle convertion is "xyz"
6868
"""
69+
70+
# TODO: Still needs to check if it is right
71+
# Some problem seems related with this function
6972
x = matrix.translation.x * 0.01 # cm to m
7073
y = matrix.translation.y * 0.01 # cm to m
7174
z = matrix.translation.z * 0.01 # cm to m

Add-IN/ACDC4Robot/core/mjcf.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,18 @@ def get_mjcf_body(link: Link, parent_link: Link = None) -> Element:
3838
"""
3939
body_ele = Element("body")
4040
body_name: str = link.get_name()
41-
if parent_link == None:
41+
if parent_link is None:
4242
# a root of a body tree
43-
pose = math_op.matrix3d_2_euler_xyz(link.pose)
43+
# pose = math_op.matrix3d_2_euler_xyz(link.pose)
44+
pose = math_op.matrix3d_2_pose(link.pose)
4445
pos_attr = "{} {} {}".format(pose[0], pose[1], pose[2])
4546
euler_attr = "{} {} {}".format(pose[3], pose[4], pose[5])
4647
else:
4748
parent_frame: adsk.core.Matrix3D = parent_link.pose # parent_frame w.r.t world_frame
4849
child_frame: adsk.core.Matrix3D = link.pose # child_frame w.r.t world_frame
4950
parent_T_child: adsk.core.Matrix3D = math_op.coordinate_transform(parent_frame, child_frame)
50-
pose = math_op.matrix3d_2_euler_xyz(parent_T_child)
51+
# pose = math_op.matrix3d_2_euler_xyz(parent_T_child)
52+
pose = math_op.matrix3d_2_pose(parent_T_child)
5153
pos_attr = "{} {} {}".format(pose[0], pose[1], pose[2])
5254
euler_attr = "{} {} {}".format(pose[3], pose[4], pose[5])
5355

@@ -184,8 +186,9 @@ def get_mjcf(root_comp: adsk.fusion.Component, robot_name: str, dir: str) -> Ele
184186
# Here we use an extrinsic X-Y-Z rotation
185187
# compiler_ele = ET.SubElement(root, "compiler",
186188
# {"angle": "radian", "meshdir": (dir + "/meshes"), "eulerseq":"XYZ"})
189+
# Rotation matrix to euler in "xyz" seems have problem, use "XYZ" at temporary
187190
compiler_ele = ET.SubElement(root, "compiler",
188-
{"angle": "radian"})
191+
{"angle": "radian", "eulerseq":"XYZ"})
189192

190193
# add asset subelement of mujoco
191194
asset_ele = ET.SubElement(root, "asset")

0 commit comments

Comments
 (0)