ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
4

Use identical package.xml for ROS1 and ROS2 pkgs

asked 2018-03-28 22:30:55 -0600

Skyking gravatar image

updated 2018-03-29 01:32:27 -0600

gvdhoorn gravatar image

What would be the general package.xml strucutre in order to compile a package for both ROS1(catkin) and ROS2(ament) ? It would be very helpful if gives an example for doing this.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2018-03-29 11:15:17 -0600

Dirk Thomas gravatar image

The REP 149 which specifies format 3 of package.xml files addresses exactly this use case.

The assumption is that a ROS package which want to support both major ROS versions will have consistent header information (name, version, license, maintainer, etc.) and only diverges in dependencies (e.g. in ROS 1 using roscpp, in ROS 2 using rclcpp).

The new condition attribute on dependency tags allows you to express that:

<depend condition="$ROS_VERSION == 1">roscpp</depend>
<depend condition="$ROS_VERSION == 2">rclcpp</depend>

The environment variable ROS_VERSION is provided by the new package ros_environment package which is available as of ROS Kinetic as well as ROS Ardent

edit flag offensive delete link more

Comments

1

But there's no way to conditionally change a package's build_type as far as I understand, and the only build_type that's common to both ROS and ROS 2 is cmake. I don't actually know the nuances of how catkin vs cmake packages are built outside of bloom release templates but I imagine there is one.

nuclearsandwich gravatar image nuclearsandwich  ( 2018-03-29 11:32:05 -0600 )edit

That's a good point.

William gravatar image William  ( 2018-03-29 11:48:56 -0600 )edit

So is there a way to use this to build pure cmake packages for both ros 1 and 2 with a single package.xml? AFAICT the respective build_types are cmake and ament_cmake . See the discussion at https://github.com/strasdat/Sophus/pu... and the linked package.xml files.

demmeln gravatar image demmeln  ( 2018-04-15 03:34:15 -0600 )edit

For pure CMake it is just cmake In both cases.

William gravatar image William  ( 2018-04-15 11:15:16 -0600 )edit

Ah I see. Is there documentation for plain cmake packages with ament somewhere? For example, should you add something like an exec depend on catkin, which is suggested for pure cmake packages in catkin (to make sure the setup files are there when the package is installed)?

demmeln gravatar image demmeln  ( 2018-04-15 15:16:58 -0600 )edit

Or is there an example?

demmeln gravatar image demmeln  ( 2018-04-15 15:17:13 -0600 )edit

It's recommended to depend on catkin from pure cmake packages, but we removed that need in ament, since the build tool, and not the package itself, now creates the root setup.sh files. We create the setup.sh files if needed in a "workspace package".

William gravatar image William  ( 2018-04-15 21:11:49 -0600 )edit

@nuclearsandwich addressed this in our ament debian packages with the injected dependency on the ros_workspace ( http://repo.ros2.org/status_page/ros_... ) package.

William gravatar image William  ( 2018-04-15 21:14:23 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2018-03-28 22:30:55 -0600

Seen: 816 times

Last updated: Mar 29 '18