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 -0500

Skyking gravatar image

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

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 -0500

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 -0500 )edit

That's a good point.

William gravatar image William  ( 2018-03-29 11:48:56 -0500 )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 -0500 )edit

For pure CMake it is just cmake In both cases.

William gravatar image William  ( 2018-04-15 11:15:16 -0500 )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 -0500 )edit

Or is there an example?

demmeln gravatar image demmeln  ( 2018-04-15 15:17:13 -0500 )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 -0500 )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 -0500 )edit

The googletest packages are both plain cmake, as an example: https://github.com/ament/googletest/b...

William gravatar image William  ( 2018-04-15 21:19:06 -0500 )edit

Just saw your third comment. Posted the answer by accident. The example is helpful, thanks!

demmeln gravatar image demmeln  ( 2018-04-16 03:22:13 -0500 )edit

Btw, how do we deal with the different build_type for ros 1 and ros 2 for regular catkin / ament packages? As @nuclearsandwich pointed out above, the conditions are only for dependencies only, or are they not?

demmeln gravatar image demmeln  ( 2018-04-16 03:24:39 -0500 )edit

@William@Dirk Thomas, is there a solution in sight for the issue concerning build_type for a mixed ros1 / ros2 package?

demmeln gravatar image demmeln  ( 2018-04-22 17:48:44 -0500 )edit

@William@Dirk Thomas, friendly ping about the issue concerning different build_type for mixed catkin / ament packages (not pure-cmake). Is there any solution is sight or already implemented? Maybe I'm missing something...

demmeln gravatar image demmeln  ( 2018-05-02 03:35:22 -0500 )edit

If you use the same built type in both (basically <build_type>cmake</build_type> is the only one that would be supported) then you can do it. I believe we'll need some additional changes to the package.xml format to support conditional build type, but no one has followed up yet.

William gravatar image William  ( 2018-05-02 15:49:39 -0500 )edit

Thanks for confirming the current state. Just for the record, an alternative to changing package format again would maybe be if the build system(s) would support or translate more identical build_types (rather than just cmake as is now).

demmeln gravatar image demmeln  ( 2018-05-04 03:59:37 -0500 )edit
William gravatar image William  ( 2018-05-16 16:27:33 -0500 )edit

I see where the changes to the REP were merged, but it doesn't look like the condition on build_type is being checked in the current version of ament. Is this on the roadmap or is there another suggestion for making ROS1 and ROS2 packages co-exist?

david.hodo gravatar image david.hodo  ( 2018-12-06 17:55:40 -0500 )edit

Question Tools

2 followers

Stats

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

Seen: 712 times

Last updated: Mar 29 '18