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

How to determine if a package is ROS1 or ROS2?

asked 2022-11-29 16:36:09 -0500

Carter12s gravatar image

updated 2022-11-30 13:02:34 -0500

I'm working on getting roslibrust to support ros2. What I am hoping to do is look at a directory, determine if it is a ROS1 or a ROS2 package, and then use the appropriate message parsing logic depending on the package type.

I'm looking for the canonical way for a tool to determine if a given package is a ROS1 or a ROS2 package.

The best I've been able to tell I should do this by looking for <buildtool_depend> in package.xml and assume it is a ROS1 package if I find catkin, and a ROS2 package if I find ament_cmake. I'm worried however that this method is not universal, as <buildtool_depend> is not listed as a required tag here.

Is there a better way? Can someone point me to documentation?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-11-30 05:28:54 -0500

gvdhoorn gravatar image

updated 2022-11-30 05:29:55 -0500

I don't believe there is a canonical way to determine this.

You'd have to rely on circumstantial evidence, as you already describe.

ROS 2 packages wouldn't/shouldn't depend on anything to do with Catkin, but there are exceptions, like the ros1_bridge (here fi). That's not a common thing to do though, but enough to be able to say: you can't strictly rely on this.

That would leave implementing heuristics, which you've already done I believe.

What I am hoping to do is look at a directory, determine if it is a ROS1 or a ROS2 package, and then use the appropriate message parsing logic depending on the package type.

If you're mostly interested in messages, I would check the package.xml for dependencies on message_runtime, message_generation, rosidl_default_generators and rosidl_default_runtime. The former two: good chance it's a ROS 1 package with messages/services. Latter two: ROS 2. In CMakeLists.txt you'd expect to see rosidl_generate_interfaces(..) for ROS 2, and generate_messages(..) for ROS 1.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2022-11-29 16:36:09 -0500

Seen: 985 times

Last updated: Nov 30 '22