how to get rotation matrix from quaternion in python
I can see tf.transformations have a matrix to quaternion function, but is there a way to do the opposite in python?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
I can see tf.transformations have a matrix to quaternion function, but is there a way to do the opposite in python?
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.
The tf.TransformerROS
class has a fromTranslationRotation
method that will turn a translation and quaternion into a 4x4 matrix representation. If you set the translation to zero then it will give you just the rotation in the matrix. The asMatrix
method is also relevant if you have just the target frame, because it will also do the lookup for you.
pretty simple to code start here
Asked: 2019-05-30 12:19:46 -0500
Seen: 9,099 times
Last updated: May 31 '19
Import .obj .mtl and .png into Gazebo [closed]
Apt Install Ros Kinetic Problem after recent update
Ackermann Steering and Arduino Servo Control
difference between execute_cb and goalcb?
gps waypoints are not shown in mapviz
Moveit planning methods failing issue
Timestamps of static transforms
[SOLVED] fedora: rqt_plot runtime error
Distance to clustering PointCloud2
Fanuc robot slows down at each trajectory point despite CNT is set to 100