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&)'
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>