I’ve been MIA in the robotics/ROS scene for a while, just coming back to revive some old work and port it to ROS2.
I have, in the past, created dual ROS1+ROS2 packages (that work in both colcon and catkin), e.g.
I’m however having trouble figuring out a way to do the same for a C++ node since I can’t use the same conditionals in CMakeLists.txt. Here’s my best shot at an update of my BNO055 I2C node in C++:
As you can see there are two CMakeLists.txt files, one for ROS1 and one for ROS2. Copying the correct one to “CMakeLists.txt” will enable this repo to work in ROS1 or ROS2 respectively.
Is there any way to combine these two into one CMakeLists.txt and avoid the extra step?
The second way is to create a vanilla cmake package. That means to avoid using catkin or ament macros. This has some downsides, because you’d have to to more work in your package. For example you need to install your package.xml. Correctly export your library and install a PackageConfig.cmake file in the correct location. But this can work, and is useful for ROS agnostic C++ libraries.
I wasn’t aware of that repo when I created mine, but it looks like a Python driver. Mine is C++ and much less CPU usage at high data rates. I should probably also add a UART version, mine only does I2C at the moment but it is fairly easy to add that.
Mine is also targeted at supporting both ROS1 and ROS2.