Ask Your Question

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

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



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 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 files. We create the 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 ( ) package.

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



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

Seen: 311 times

Last updated: Mar 29 '18