geometry2 icon indicating copy to clipboard operation
geometry2 copied to clipboard

New approach for the tf2::toMsg() hassle

Open gleichdick opened this issue 4 years ago • 3 comments

The second template parameter of tf2::toMsg() now has a default value, which is resolved to a ROS message type depending on the non-message datatype. This allows the deduction of the return value type.

Furthermore, toMsg(), fromMsg(), getTimestamp() and getFrameId() now have a default implementation, which forwards the calls into structs defined in the impl namespace. Now missing implementations of conversion methods result in compile-time errors, they do not occur during link-time anymore.

A lot of effort was put into the automatic conversion of dataypes with a stamp (tf2::Stamped<T> and the ...Stamped ROS messages) to avoid code duplication. The stamped types now use the conversion methods of the unstamped types and copy the timestamp/frame id informations.

This PR should remain API compatibility, but the ABI will break (as the non-templated functions like toMsg() are removed).

Further TODO's:

  • [ ] extend documentation
  • [ ] test downstream packages

@seanyen may I ask you to test whether this approach works on Windows?

Related Issues: #430 ros-planning/moveit#1785

gleichdick avatar Dec 11 '20 13:12 gleichdick

@tfoote friendly ping

gleichdick avatar Jan 22 '21 11:01 gleichdick

Thanks for this. It's going to take me a bit to review this fully.

As this will break ABI as a core module we generally won't want to roll it out into an active rosdistro for something quite this core without a significant problem. Would it make sense to target this for ROS 2 rolling instead of noetic. If we get it into rolling soon we can also shoot to get it into the upcoming Galactic release.

tfoote avatar Jan 25 '21 02:01 tfoote

Okay, thanks. I'm currently porting this to ROS2, see ros2/geometry2#368.

gleichdick avatar Jan 26 '21 23:01 gleichdick

I guess this ROS 1 PR can be closed.

peci1 avatar Apr 09 '23 22:04 peci1

This is something that we definitely can't change in ROS 1 distributions. I'm going to close this and point to the open PR on the ROS 2 repo: https://github.com/ros2/geometry2/pull/427 for further discussion.

tfoote avatar Sep 22 '23 08:09 tfoote