Ask Your Question

Counterpart to pcl_ros::transformAsMatrix ?

asked 2012-07-01 08:13:39 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.


I understand pcl_ros::transformAsMatrix(const tf::Transform& bt, Eigen::Matrix4f &out_mat) can be used to convert a tf::transform to a 4x4 matrix describing the same transformation.

I am now looking for a method that does the same thing backwards, converting a 4x4 matrix to a tf::transform.

Is such a method already implemented somewhere?


EDIT: Solution that works for me, thanks to Eric:

  Eigen::Matrix4f mf; //The matrix I want to convert
  Eigen::Matrix4d md(mf.cast<double>());
  Eigen::Affine3d affine(md);
  tf::Transform transform;
  tf::TransformEigenToTF(affine, transform);
edit retag flag offensive close merge delete



A small info which might be helpful for others. For ROS hydro, tf::transformEigenToTF must be used.

balakumar-s gravatar image balakumar-s  ( 2013-11-30 06:55:54 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2012-07-01 10:43:22 -0500

Eric Perko gravatar image

You should look at the tf_conversions package, specifically the tf::TransformEigenToTF function.

You would have to make an Eigen::Affine3d from your Eigen::Matrix4f. See the Eigen Geometry Module Tutorial (and linked docs for each class) for information on how to go about that. I expect it involves a conversion from Matrix4f to Matrix4d and then passing that to the Affine3d constructor, but I don't know the exact function calls and syntax required off the top of my head.

edit flag offensive delete link more


Works, thank you.

jodafo gravatar image jodafo  ( 2012-07-01 12:39:25 -0500 )edit

The Eigen Geometry Module Tutorial no longer exists. Is there an updated version?

bzr gravatar image bzr  ( 2014-12-02 09:57:22 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-07-01 08:13:39 -0500

Seen: 3,040 times

Last updated: Oct 14 '13