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

rospy convert matrix to transform

asked 2015-07-06 15:47:25 -0500

dinosaur gravatar image

How would I convert a 4x4 numpy matrix to (translation, quaternion) using tf (or some other package package) in python?

On the wiki for python tf, I found the method fromTranslationRotation, which converts (translation, quaternion) to numpy matrix. What's the method that does the inverse operation?

The context (though I'm not sure this is relevant) is to connect two tf trees.

/camera_1
    /ar_marker_1 

/camera_2
    /ar_marker_2

I can't easily measure the transform between camera_1 and camera_2, so I've placed AR markers where I can easily measure the transform between them, and one camera can see each marker. I know the transform between ar_marker_1 and ar_marker_2, but tf trees have to be connected by the root, so I've used matrices to compute the transform from ar_marker_1 to camera_2, but now I can't figure out how to publish that transform because it's a matrix, not a (translation, quaternion).

edit retag flag offensive close merge delete

Comments

Here's a related question in c++: http://answers.ros.org/question/10341...

dinosaur gravatar image dinosaur  ( 2015-07-06 17:56:45 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-07-06 17:54:30 -0500

dinosaur gravatar image

tf.transformations.decompose_matrix is able to get the translation, rotation and more from a matrix. Example usage:

    scale, shear, rpy_angles, translation_vector, perspective = \
        tf.transformations.decompose_matrix(transformation_matrix)

The source code is here.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-07-06 15:47:25 -0500

Seen: 2,377 times

Last updated: Jul 06 '15