How to determine if a package is ROS1 or ROS2?
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 catkin
, and a ROS2 package if I find ament_cmake
. I'm worried however that this method is not universal, as
Is there a better way? Can someone point me to documentation?
Asked by Carter12s on 2022-11-29 17:36:09 UTC
Answers
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.
Asked by gvdhoorn on 2022-11-30 06:28:54 UTC
Comments