This repository was archived by the owner on May 31, 2025. It is now read-only.
Fix tf2::convert for non-msgs types #433
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
At the moment, when you use
tf2::convert()with two types which are not from geometry_msgs package (i.e.tf2::Vector3andEigen::Vector3d) linking errors can occur. See #430 for details.This PR changes all overloads of
fromMsg()andtoMsg()to be template specialisations so that the correct overload is found bytf2::convert()independ of the header include order.A Python script creates mappings between non-msgs types with forward declarations, an example of its output can be found here. The script runs with Python 2 and 3.
These mappings are picked up by
tf2::convert()with some SFINAE magic, if no mapping is found a nice error message is shown:A typemap looks like
Caveats
The signature of
toMsgis changed, this will break user code.The generated TypeMaps will be included in
<tf2/convert.h>, sotf2::Vector3,KDL::Frameand friends will always be forwad defined when including<tf2/convert.h>. So maybe the TypeMaps should be split into separate headers.Things to be done
fromMsg/toMsgsignature, how to extend three way converting)Related PRs/Issues
#430
#431
moveit/moveit#1785
moveit/moveit#1794