ros / geometry2

A set of ROS packages for keeping track of coordinate transforms.
190 stars 275 forks source link

fromMsg(const PoseWithCovarianceStamped&, tf2::Stamped<tf2::Transform>&) is broken #441

Open gleichdick opened 4 years ago

gleichdick commented 4 years ago

While I was trying to do some coverage tests for #433 I noticed that tf2::fromMsg(const geometry_msgs::PoseWithCovarianceStamped&, tf2::Stamped<tf2::Transform>&) (defined in tf2_geometry_msgs.h line 594) calls fromMsg(const geometry_msgs::PoseWithCovariance&, tf2::Transform&) which not defined.

Steps to reproduce: Compile the snipped

#include <tf2_geometry_msgs/tf2_geometry_msgs.h>

int main() {
   const geometry_msgs::PoseWithCovarianceStamped msg;
   tf2::Stamped<tf2::Transform> t;
   fromMsg(msg, t);
}

with g++ -otest $(pkg-config --cflags tf2_geometry_msgs) snippet.cpp $(pkg-config --libs tf2_geometry_msgs), the error message will be

/tmp/ccCqjqOB.o: In function `tf2::fromMsg(geometry_msgs::PoseWithCovarianceStamped_<std::allocator<void> > const&, tf2::Stamped<tf2::Transform>&)':
test2.cpp:(.text._ZN3tf27fromMsgERKN13geometry_msgs26PoseWithCovarianceStamped_ISaIvEEERNS_7StampedINS_9TransformEEE[_ZN3tf27fromMsgERKN13geometry_msgs26PoseWithCovarianceStamped_ISaIvEEERNS_7StampedINS_9TransformEEE]+0x8c): undefined reference to `void tf2::fromMsg<geometry_msgs::PoseWithCovariance_<std::allocator<void> >, tf2::Transform>(geometry_msgs::PoseWithCovariance_<std::allocator<void> > const&, tf2::Transform&)'
collect2: error: ld returned 1 exit status

When Line 599 is changed to

-  fromMsg(msg.pose, tmp);
+  fromMsg(msg.pose.pose, tmp);

it compiles (but I have no clue whether the conversation is correct).

The methods were introduced with #282, maybe @RobertBlakeAnderson can provide an unit test which verifies the fromMsg method?