Syncronized callbacks in ROS2

REP 149 addresses the blocker of package manifests being able to declare separate ROS 1 and ROS 2 dependencies.

From a technical point of view it is then possible to have a ROS package using a single branch. The CMake logic can be made conditional based on the ROS version (the ROS 1 part using catkin, the ROS 2 part using ament). And the source code needs to distinguish between the ROS versions using whatever approach preferred (based on preprocessor definitions and/or conditional includes in C++, conditional imports in Python).

Of course anything which reduces differences between the ROS versions makes this more convenient and requires less conditional logic, e.g. typedefs, API shims, etc. On the other hand if a ROS package would like to use features from ROS 2 which aren’t available in ROS 1 (e.g. multiple nodes in a single executable) than the code will need to be different for that.

1 Like