Skip to content

Instantly share code, notes, and snippets.

@rpapallas
Last active March 5, 2018 13:50
Show Gist options
  • Save rpapallas/6197677403f7fcbcc3ed6d1eee0149ee to your computer and use it in GitHub Desktop.
Save rpapallas/6197677403f7fcbcc3ed6d1eee0149ee to your computer and use it in GitHub Desktop.
OpenRAVE: Given a transform 2D list of an object it will return back the translation and rotation as separated XML elements to be used in an environment.xml file.
def get_xml(arr):
rotation = "<RotationMat>"
for row in range(0, 3):
for col in range(0, 3):
rotation += str(arr[row, col])
if row != 2 or col != 2: rotation += " "
rotation += "</RotationMat>"
translation = "<Translation>"
for row in range(0, 3):
translation += str(arr[row][3])
if row != 2: translation += " "
translation += "</Translation>"
combined = translation + "\n" + rotation
print combined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment