ROS1: Now is a great time to add `catkin_lint` to your packages!

catkin_lint is an established ROS package that can do lots of useful checks on your CMakeLists.txt and package.xml . It can e.g. warn you about dependencies that do not match between package.xml and CMakeLists.txt, it can check existence of all rosdep keys in pacakge.xml, it will watch if all executable files in your package get installed, it will warn you about the most common wrong usages of CMake, and recently it even got the ability to warn you if you’re using a CMake feature that is too new for the CMake version you’ve put in cmake_minimum_required(). And there’s much more.

Personally, as a maintainer, I feel much more comfortable releasing a new version of a package once I see catkin_lint passed without complaints.

Until recently, automatic running of catkin_lint tests on packages released via buildfarm was problematic because the buildfarm doesn’t initialize rosdep cache and catkin_lint needed it for its working. The recently released version 1.6.22 of catkin lint no longer fails in this case, so it is able to run all other tests that do not require rosdep on the buildfarm, while disabling those that need rosdep (currently only checking that package.xml keys point to existing packages).

Adding automatic catkin_lint to your package is easy!

CMakeLists.txt:

if (CATKIN_ENABLE_TESTING)
  find_package(roslint REQUIRED)
  roslint_custom(catkin_lint "-W2" .)
  roslint_add_test()
endif()

package.xml:

<test_depend>python3-catkin-lint</test_depend>
<test_depend>roslint</test_depend>

And that’s it!

If you want to run the test locally, you can either manually invoke catkin_lint . in your package directory, or make roslint in the build directory.

And if you’re okay with some warnings catkin_lint gives you, you can always ignore them either for a single line (#catkin_lint: ignore_once duplicate_find) or globally by adding arguments to the catkin_lint call (catkin_lint -W2 --ignore duplicate_find .).

Of course, the catkin_lint automation should not substitute manual runs of this tool before releasing a new version of your package. It should be a good habit to run caktin_lint after you finished editing your build files. However, having the automation built in, you can get assurance that even if you forget running the tool manually, the buildfarm will let you know :slight_smile:

You can see examples of catkin_lint used on buildfarm-released packages e.g. in our ROS utils stack: ros-utils/cras_topic_tools/CMakeLists.txt at master · ctu-vras/ros-utils · GitHub . Or scroll down on rosdep System Dependency: python3-catkin-lint to see all other.


NB: I’m not the developer of catkin_lint. @roehling @ FKIE is doing all of the awesome work!


NB2: When you’re at it, also have a look at:

find_package(roslaunch REQUIRED)
roslaunch_add_file_check(launch IGNORE_UNSET_ARGS)

and

<test_depend>roslaunch</test_depend>
11 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.