New ROS Development Python Tools - ros_glint, ros_command and more

tl;dr: Five new Python libraries to help with ROS development are available now via pip:

  • ros_glint - a ROS 1 and 2 linter that evolved from roscompile
  • ros_command - command line tools previously announced here
  • ros_introspect - Pure Python version of the ROS 1 package ros_introspection
  • stylish_cmake_parser - Parser for CMake files with the ability to retain the whitespace “style” after modifying
  • betsy_ros - A helper library with several ROS 1 & 2 “meta” operations, used by the above tools

Background

Back in 2015, I released a tool called roscompile with the goal of automating all the annoying meta-information in catkin packages. It largely stems from the fact that I’m bad at remembering to install stuff in CMake and that I wrote so many pluginlib plugins that it made sense to automate the process of writing the plugin definition files. I talked about it in my ROS World 2020 Lightning Talk.

But roscompile only works for ROS 1. And rather than port it directly, and maintain two separate versions of the code, I made the questionable decision to make a new library that handled both ROS 1 and ROS 2, and was not a ROS package at all, but an independent python package.

The result is the above five Python packages, available via pip.

ros_glint

“Make your ROS code sparkle!”

Run glint_ros in any folder with ROS packages (1 or 2) and it will suggest meta-data fixes interactively for you to apply.

  • Add missing dependencies to package.xml
  • Replace the default license/author names
  • Generate CMake code to build ROS messages, etc.
  • Link your C++ libraries/executables with the proper libraries
  • Make sure all the important package files are installed
  • Clean up whitespace in many places
  • Generate plugin definition files
  • Generate setup.py files
  • Remove default settings from .rviz files
  • And much much more…

New features:

I prioritized testing over documentation on this one, and I know I’ll need to circle around to that eventually.

ros_command

I announced ros_command over two years ago, and now its available as a pip package. Other new features in that time:

  • roslaunch implemented
  • New command rosexecute for doing either a launch file or a node
  • Tab completion - This makes me feel like a real Python dev.
    • The package completer works in rosbuild, roscd, rosrun and roslaunch
    • Executable completer works in rosrun and rosexecute
    • The launch file completer in roslaunch and fixing something that really grinds my gears, doesn’t suggest --print and all the other args as completions when trying to remember the name of a launch file.
    • Also autocompletes launch file arguments.
    • ROS interfaces (messages/services/actions) can be autocompleted starting with either the package name or the interface name.
  • Also, the list of canonical emojis for each distro has been updated, although I’m struggling to figure out what to do for Kilted Kaiju. Maybe :small_red_triangle:

Other Libraries

  • stylish_cmake_parser also spun out of roscompile and is the only parser that can properly manipulate the “style” of the CMake in addition to the actual commands. Preliminary tests showed it successfully parsing 13351/13395 (99.67%) CMake files found in the rosdistro.
  • ros_introspect gives you the ability to classify all the files in a ROS package folder into different classes and then perform some operations on them. Used throughout ros_glint
  • betsy_ros contains a bunch of Python functions that are needed for the other tools to work in ROS 1 or 2.
    • get_workspace_root determines the type and location of the current workspace
    • get_package_name_from_path reads the package.xml so you don’t have to.
    • ROSInterface is an independent class for ROS messages/services/actions.
    • and more…

Final Thoughts

  • Please use these libraries as a jumping off point for your own ROS script hacking. I’ve thought about making a Github bot with it, and am still working on releasing an updated ROS 1 → ROS 2 conversion tool.
  • Despite the polish and branding that I have given these, they are still “hobby” projects and are likely to have bugs that I encourage you to report. I’m not perfect.
  • It is ridiculously easy to release pip packages once you get the hang of it. I have to credit the Scientific Python Library Development Guide as being a great starting resource. But also, there’s not actually any other human action required for getting stuff into pip, which I’ve found contrasts distinctly with the multiple rounds of PRs that you need to get stuff into the ROS distro.
  • I’ve also made a Python DB wrapper based on my ros_metrics work and a Python Google API wrapper if you want to know where my “spare” developer cycles have been.
  • I use my own tools daily, and I think they’re very useful. If you do too, please drop me a line. It makes the community feel more tight knit. Or, as the kids say, likeandsubscribe.
10 Likes

Thanks David, love seeing the “hacker” spirit that made ROS successful to begin with. Looking forward to trying some of these out.

And ring that bell!

1 Like

Promising! I ran into some issues with ros_glint and opened up an issue and PR.

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