Open gleichdick opened 4 years ago
Hint: If you can provide a PR (and I believe you can based on your analysis of the issue), the issue has higher chances to be fixed soon.
Well, this whole template stuff isn't that easy. I tried adding template<>
on each fromMsg()
and toMsg()
overload (in general the bug also applies to toMsg
), but that does not work because one template parameter is the return value toMsg
(return values are not taken into account for template parameter deduction). GCC complains:
out.orientation = toMsg(in.getRotation());
^
In file included from /ws_moveit/install/include/tf2/convert.h:35:0,
from /ws_moveit/install/include/tf2_geometry_msgs/tf2_geometry_msgs.h:35,
from test.cpp:3:
/ws_moveit/install/include/tf2/transform_functions.h:90:5: note: candidate: template<class A, class B> B tf2::toMsg(const A&)
B toMsg(const A& a);
^~~~~
/ws_moveit/install/include/tf2/transform_functions.h:90:5: note: template argument deduction/substitution failed:
In file included from test.cpp:3:0:
/ws_moveit/install/include/tf2_geometry_msgs/tf2_geometry_msgs.h:427:43: note: couldn't deduce template parameter ‘B’
out.orientation = toMsg(in.getRotation());
^
possible solutions:
template<>
everything1 and 2 still rely on the correct order of header includes (tf2_geometry_msgs.h before tf2/convert.h), so these options aren't bullet proof.
Number 3 clutters up the headers but keeps backward compatibility and does not rely on the include order.
Number 4 breaks everything, as toMsg
has to be specified manually on each call. Maybe in the next release, the signature could be changed so that every parameter could be deducted.
A tf2::toMsg(const B&)
calls to either A& tf2::toMsg(const B&, A&)
or tf2::convert(const B&, A&)
. The latter one is backwards compatible (except for three-way conversions).@rhaschke moveit melodic-devel compiles with these changes (with moveit_visual_tools updated as well). Should I open a PR for it to make a review easier?
I build moveit and geometry2 from source, importing moveit_commander python module throws an ImportError due to missing symbol. See ros-planning/moveit#1785. Reverting #367 fixes the issue.
With HEAD pointed to cd55e45, following snippet (extracted from here) builds fine:
With current melodic-devel (#367 applied, 1cbda1e14), the symbol is also missing:
The function is declared in tf2_geometry_msgs.h as
inline
, but nottemplate<>
. If I got it right, the declaration order is:template<class A, class B> fromMsg(const A&, B&);
template<class A, class B> void convert(const A&, B&) {...}
inline void fromMsg(const geometry_msgs::Quaternion &, tf2::Quaternion&) {...}
So, in
impl::convert
the correct overload is not found because it is defined as a stand-alone function afterwards (I guess).When
template<>
is added to thefromMsg
overloads, the snippet compiles.