Over the few years I’ve been developing with ROS, I’ve gradually accumulated a collection of habits in how I structure new packages, how I configure my developer tools, etc. These typically get copied from one package to the next as I go along. However I feel that my practices are hardly best practices; there are definitely areas I’m lacking in, such as writing tests, or packaging my nodes for release.
In many other frameworks there exist tools for spinning up a new project from a standard template that incorporates best practices and a baseline configuration for tooling. For example, there’s
create-react-app, or the more generic
cookiecutter. These provide a very good developer experience, are easier than starting from scratch.
I’d like to brainstorm some ideas for how similar templates and tooling could enhance the ROS developer experience.
Ideally, the way the developer interacts with the template is by running a tool to create the project directory from a chosen template. Possibly, as is common in the Node world, the tool could also provide a wrapper around common tasks like build, test, etc. – but it should be transparent about what commands are being executed.
The intended audience is any ROS developer, not just new users (who benefit from the handholding a tutorial provides). The template accelerates the process of creating a new package, improves the developer experience, and assists in delivering quality code. It is not an “easy mode”.
I want to distinguish these templates from tutorials, which have an educational aim and therefore need to be explanatory. Undoubtedly it would be a good thing if there exist, in parallel, tutorials that refer to these templates.
Generally, a template strike a balance between function and minimalism. I would prefer to avoid extensive, boilerplate comment blocks that explain what every line in CMakeLists.txt does, as this belongs elsewhere.
It’s arguable whether these templates are considered examples or how-tos of how to do accomplish some task in ROS, like using
image_transport. Undoubtedly there will be some overlap. However the intention is not to cover every use case and to rely on the existing documentation.
Lastly, I want to acknowledge that there exists
catkin create pkg but this mainly (or only?) produces boilerplate
Here are some initial ideas for things to include in these templates, to kick off the discussion:
- Unit tests (and other kinds of tests)
- CMakeLists.txt and package.xml
- Launch scripts
- Dev containers
- Integrated linter / code formatter
- Continuous integration (GitHub CI, ROS Build Farm)
- With setup.py
- Both sync and async templates
- Using type hints
- Using modern C++1x or 2x
- Building .deb packages
- Building container images
Other client libraries or implementations: Roslib.js, micro-ROS, “raw” DDS
Common (basic) patterns
- Subscribers, publishers, actions, services
- State machines
- Message filters
Other questions for the community:
What would the ideal developer experience look like to you? What other frameworks or templating tools provide good developer experiences?
Is there enough consensus about what best practices even are in ROS?
How do we strike the balance between satisfying the needs of experienced users and beginners alike?
Are there existing packages that are good role models?