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

Possible to build pure python package for ros1 and ros2 with one package.xml/CMakeLists file?

asked 2019-10-15 19:45:59 -0500

Jari gravatar image

I have a pure python pacakge. Currently I have a CMakeLists and package.xml file set up so that it builds correctly with ros 1. If I add the ament_python build type to my package.xml then it also works great for ros 2 but then I can't build it for ros 1.

Is there any way out of this that doesn't require me to keep two branches/separate ros2 repo (that isn't writing a giant cmake file with lots of conditionals)?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2019-10-16 12:00:38 -0500

Dirk Thomas gravatar image

As of format version 3 of the package manifest the build_type tag supports a condition attribute (see REP 149) which allows you to specify two different build types - e.g. one for ROS 1 and another for ROS 2.

edit flag offensive delete link more

Comments

Excellent. Can I use this now or is this coming in a future update?

Jari gravatar image Jari  ( 2019-10-16 17:26:50 -0500 )edit
1

That feature is already available for quite some time. So you can use it now.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-10-16 17:32:25 -0500 )edit

So apparently this works for catkin only if I put in two build_type tags and ensure that the cmake build type tag with condition $ROS_VERSION == 1 is listed first.

As far as I can tell catkin is ignoring that tag whereas colcon seems to be using it correctly. Does that sound right?

Edit: the condition that does work (and it's great that it does) is <export> <build_type condition="$ROS_VERSION == 1">cmake</build_type> <build_type condition="$ROS_VERSION == 2">ament_python</build_type> </export>

Jari gravatar image Jari  ( 2019-10-17 17:40:41 -0500 )edit

I would certainly call that a bug. Would you mind trying https://github.com/ros/catkin/pull/1038 and comment if that resolves the problem for you.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-10-17 18:11:45 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2019-10-15 19:45:59 -0500

Seen: 155 times

Last updated: Oct 16 '19