ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

you can import tf.transformations and use the many functions defined there the code itself can be found here

from tf.transformations import quaternion_matrix
matrix = quaternion_matrix([1, 0, 0, 0])

Just be careful for what you type in, I think the order here if you use a quaternion from a ros message would be [quat.w, quat.x, quat.y, quat.z]

you can import tf.transformations and use the many functions defined there the code itself can be found here

from tf.transformations import quaternion_matrix
matrix = quaternion_matrix([1, 0, 0, 0])

Just be careful for what you type in, I think the order here if you use a quaternion from a ros message would be [quat.w, quat.x, quat.y, quat.z]

EDIT: the version coming with ROS Kinetic is quite old and uses the input [quat.x, quat.y, quat.z, quat.w], the updated version on the link uses the reversed input shown above.