Trying to turn my project lanelet2 into a hybrid ROS1/ROS2 package (one that can be used in both ROS versions) I ran into some troubles.
The problem is migrating the metapackage
lanelet2, because of the inconsistent treatment of metapackages between ROS1 and ROS2. Imho it would make sense to make the package conditionally depend on
ament_cmake, depending on the value of
ROS_VERSION, so that the package.xml essentially looks like this (real file is here):
<buildtool_depend condition="$ROS_VERSION == 1">catkin</buildtool_depend> <buildtool_depend condition="$ROS_VERSION == 2">ament_cmake_core</buildtool_depend> <!-- exec_depends on the other packages go here... --> <export> <build_type condition="$ROS_VERSION == 1">catkin</build_type> <build_type condition="$ROS_VERSION == 2">ament_cmake</build_type> <metapackage/> </export>
However this produces warnings with
catkin_pkg in both ROS1 and ROS2, because the package.xml no longer complies with REP 149 since other
catkin are not allowed.
So what is the best solution here?
- Live with the warnings, but that is obviously not ideal
- Try to get a patch into
catkin_pkgto tolerate conditional
amentdependencies, but then REP 149 is still not followed
- Leave away the metapackage tag (as suggested for ROS2). But afaik ROS1 still relies on it, e.g. for building the package documentation