1
Eigen::Affine3f transform_temp = (Affine3f)transforms[i]; 
const Eigen::Matrix3d rotation_part = transform_temp.rotation().cast<double>();
const Eigen::Vector3d translation_part = transform_temp.translation().cast<double>();
tf::Matrix3x3 rot;
tf::Vector3 tra;
tf::matrixEigenToTF(rotation_part, rot);
tf::vectorEigenToTF(translation_part, tra);
tf::Transform temp_transform(rot, tra);

listener->lookupTransform (link, msg_in->header.frame_id, ros::Time(0), tfTransform);

broadcaster->sendTransform(tf::StampedTransform(tfTransform * temp_transform.inverse(), ros::Time::now(), link,  "chess_board"));

I got the following error. Do not know why, I have find_package(catkin REQUIRED COMPONENTS tf tf_conversions) and also target_link_libraries(${catkin_LIBRARIES})

undefined reference to `tf::matrixEigenToTF(Eigen::Matrix<double, 3, 3, 1, 3, 3> const&, tf::Matrix3x3&)'
mrry
  • 125,488
  • 26
  • 399
  • 400
Johnnylin
  • 507
  • 2
  • 7
  • 26
  • I can manually transform this by just copying the tf::matrixEigenToTF() code. But still do not know why calling this function directly does not work. – Johnnylin Oct 14 '15 at 06:06

1 Answers1

3

You have to set up you CMakeList.txt as shown in this answer to properly include Eigen in your project.

Also, you don't need to split the affine transform in the rotation and traslation components (have a look at Eigen-tf conversion).

Eigen::Affine3f transform_eigen = (Affine3f)transforms[i];
tf::Transform transform_tf;
tf::transformEigenToTF(transform_eigen, transform_tf);

EDIT: I have suddenly thought about Eigen library and not about what could be actually the problem. Have you added the tf_conversions dependency in the package.xml file? You have not mentioned it. Also, you have to include the library: #include <tf_conversions/tf_eigen.h>

user3079474
  • 1,653
  • 2
  • 24
  • 37
alextoind
  • 1,143
  • 1
  • 13
  • 20
  • I have include the file tf_eigen.h, but my package does not need a package.xml. My project just depend on tf. And including tf_eigen.h only make tf::vectorEigenToTF(translation_part, tra) this function pass the compilation but i do not know why tf::matrixEigenToTF gets an error. – Johnnylin Oct 14 '15 at 13:55
  • 1
    Sorry, I've assumed it was a ROS application. Can you please add the complete CMakeList.txt? – alextoind Oct 15 '15 at 07:05