Skip to content

Instantly share code, notes, and snippets.

@stfuchs
Last active January 25, 2019 02:20
Show Gist options
  • Save stfuchs/d4514eb598cc16dd8f1b2a8535fdef61 to your computer and use it in GitHub Desktop.
Save stfuchs/d4514eb598cc16dd8f1b2a8535fdef61 to your computer and use it in GitHub Desktop.
import numpy as np
import tf.transformations as tft
def quat_to_array(msg):
return np.array([msg.x, msg.y, msg.z, msg.w])
def vec_to_array(msg):
return np.array([msg.x, msg.y, msg.z])
def from_pose_msg(msg):
return tft.compose_matrix(
angles=tft.euler_from_quaternion(quat_to_array(msg.orientation))
translate=vec_to_array(msg.position))
def from_tf_msg(msg):
return tft.compose_matrix(
angles=tft.euler_from_quaternion(quat_to_array(msg.rotation))
translate=vec_to_array(msg.translation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment