ros2 / ros2/geometry2

Change signature of tf2::fromMsg() and tf2::toMsg() to prevent linking errors.

Open
#242 3 comments 0 reactions 1 assignee View on GitHub

@clalancette is already working on this.

Since Mar 12, 2020.

enhancement
Dominant language
C++
Stars
153
Forks
256
Avg merge
3d 23h
Merged PRs (30d)
14

Description

Feature request

Make all overloads of fromMsg() and toMsg() template specializations (with template<>)

Feature description

As pointed out in ros/geometry2#430, the fromMsg() and toMsg() Methods are traditional overloads (same function name, different arguments) and not a specialization of the templated forward declarations in <tf2/convert.h>. So, sometimes the compiler chooses the wrong functions which results in linking errors like (from ros/geometry2#430):

undefined reference to `void tf2::fromMsg<geometry_msgs::Quaternion_<std::allocator<void> >, Eigen::Quaternion<double, 0> >(geometry_msgs::Quaternion_<std::allocator<void> > const&, Eigen::Quaternion<double, 0>&)'
Implementation considerations

I already made a PR on the ROS1 version (ros/geometry2#433) which declares all fromMsg() and toMsg() as template specializations. The conversion between two non-geometry-msgs types is done explicitly, the mappings are generated with the help of a python script. Implicitly mapping these types together does not work with template specializations.

Downstream projects will break, because tf2::toMsg() now has two parameters in my implementation. Otherwise, the second type couldn't be deduced as the return value does not take part in template parameter deduction. On the other hand, all calls to tf2::fromMsg() and tf2::convert() will be fine.

Related Issues/PRs

ros/geometry2#430
ros/geometry2#433
ros/geometry2#367
ros/geometry2#444
ros-planning/moveit#1785

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.