Source control, packages, and metapackages in 2021?

asked 2021-01-14 17:10:18 -0500

qTHqq gravatar image

updated 2021-01-14 17:12:53 -0500

The Actual Question

I'm trying to start a set of ROS packages for my organization for the purposes of integrating our non-ROS code into ROS as a testing environment. I will share them across the organization using Git repositories.

After some research, I feel like my favored, up-to-date strategy for organizing and distributing the code is a Git mono-repo containing my organization's ROS packages and a metapackage that logically collects them. Is this true or should I do something with vcs and rosinstall?

TL;DR Details

I've been researching this for days, and in the end, it feels like it's kind of an unanswered question with pros and cons. But I'd like the community's input. My ROS code will start simple, with a couple of packages (one being a thin ROS wrapper for our non-ROS code), but I don't expect it to remain simple, so I'm wondering a lot about recommended best (or better) practices for:

  • How to actually structure directories and files in my Catkin workspace on disk.
  • How these files should relate to Git repositories shared across our organization.

This feels like it might have a clear, suggested starting point, but there's not a lot of "official discussion" about it.

For example, I follow ROS Wiki Best Practices to the ETH Zurich Wiki which is very nice, but I come to Package Organization and it says "Group packages in stacks." Jon Bohren's nice ROS Crash Course slide decks on best practices says the same thing. Stacks appear to be a deep legacy concept, seemingly replaced by metapackages.

Most of the metapackages in ROS are backwards compatible placeholders for converted rosbuild Stacks.

There's nothing there about sharing code via repositories.


It feels like I will want to group our ROS wrapper package and our testing packages that use it into a metapackage. But this seems like a completely separate issue from how precisely to organize the actual files: how to map the directory structure in my Catkin workspace to our git repos. A metapackage seems to be an abstract collection defined by XML files. Where do the metapackage files live?

When I search ROS Answers, I mostly find answers discussing vcstool and .rosinstall files suggesting one-package-per-repo. This seems reasonable, and I can evidently use vcs to install all the needed repos at once, but it also seems to eliminate a strict need for a metapackage? (Correct me if I'm wrong.) And then, do I need a separate repo for the metapackage?

When I reach for other packages, I feel like I'm pulling mono-repos that gather a metapackage and a collection of package source code down from GitHub like universal_robot. Similarly, MoveIt, which is discussed below. This strategy doesn't seem to need vcs or rosinstall which add extra mental overhead compared to "Clone the organization ROS monorepo into your Catkin workspace, run rosdep, and run catkin_make"

I finally found

(more)
edit retag flag offensive close merge delete

Comments

I have a couple of long threads in the details below, but I'd like your recommendations.

I don't see anything else after this line?

gvdhoorn gravatar image gvdhoorn  ( 2021-01-15 00:42:12 -0500 )edit
1

Also: you only link to #q218498, but I believe there is also #q347421 (and the referenced #q264600).

re: vcstool: it just provides convenience when seeding a workspace, by reducing the nr of commands (ie: single one vs N git clones). It's not required, and obviously not helpful if you have only a single repository.

re: single pkg per repo vs mono-repo: this reads a bit like a false dilemma. There's a very sane middleground here: put things together which belong together (because they deal with the same topic, algorithm, interface with the same machine, etc, etc). Pkgs being "from the same company" is not sufficient rationale in most cases to put them in the same repository.

Finally: apart from some objective technical aspects, VCS organisation and inter-pkg relationships are part of Software Engineering, which is still largely an art. I don't believe there will be a ...(more)

gvdhoorn gravatar image gvdhoorn  ( 2021-01-15 01:12:03 -0500 )edit

This strategy doesn't seem to need vcs or rosinstall which add extra mental overhead compared to "Clone the organization ROS monorepo into your Catkin workspace, run rosdep, and run catkin_make"

I realise every additional command is one additional command, but you're referring to:

mkdir -p /path/to/your/catkin_ws/src
git clone https://...
git clone https://...
[etc]
rosdep update && rosdep install --from-paths /path/to/your/catkin_ws/src -i ...
catkin build --workspace /path/to/your/catkin_ws

vs

mkdir -p /path/to/your/catkin_ws/src
vcs import /path/to/your/catkin_ws/src --input https://.../my_repos.repos
rosdep update && rosdep install --from-paths /path/to/your/catkin_ws/src -i ...
catkin build --workspace /path/to/your/catkin_ws

?

For any project with more than a single repository (which I believe is very likely to be the case), the vcs variant seems preferable to me.

gvdhoorn gravatar image gvdhoorn  ( 2021-01-15 01:18:00 -0500 )edit

About metapackages: #q256493.

Note: they do not wrap anything (physically). Packages cannot be nested.

They're convenience collections, like the Debian metapackage concept (ie: a single package makes apt install N other packages).

None of the source and/or repository management tools I know of care about metapackages, so they only seem to really make sense in case you plan to build binary packages (ROS buildfarm, an internal one or a more manual process) and distribute them in a format some platform package manager can consume.


Edit: well, maybe you could consider a .repos file some sort of metapackage, as it has a similar role, but then for source distributions. Metapackages can depend on other metapackages though, which allows for recursive management of dependencies. .repos files cannot.

gvdhoorn gravatar image gvdhoorn  ( 2021-01-15 01:29:27 -0500 )edit

Note: they do not wrap anything (physically). Packages cannot be nested.

This is a key thing that I was missing and figured out shortly after I posted my question. The fact that catkin (or/also CMake) doesn't care about arbitrarily nested directory structures was kind of lost on me, but then I realized that the metapackage is the universal_robot folder at https://github.com/ros-industrial/universal_robot, not the whole repository.

So on my disk, the metapackage is

src\universal_robot\universal_robot

The top-level universal_robot folder in src that was retrieved by

git clone https://github.com/ros-industrial/universal_robot.git

Does not have to be arranged that way. It's arbitrary and catkin doesn't care at all about it.

In the typical ROS convention (at least following tutorial folder structures), the metapackage would just be another folder in catkin_ws\src alongside all my other packages.

qTHqq gravatar image qTHqq  ( 2021-01-15 09:01:51 -0500 )edit

None of the source and/or repository management tools I know of care about metapackages, so they only seem to really make sense in case you plan to build binary packages (ROS buildfarm, an internal one or a more manual process) and distribute them in a format some platform package manager can consume.

Understood.

Edit: well, maybe you could consider a .repos file some sort of metapackage, as it has a similar role, but then for source distributions. Metapackages can depend on other metapackages though, which allows for recursive management of dependencies. .repos files cannot.

I think the .repos file may be what I need but now I think I actually understand how to get started concretely, which was not yet clear. Makes sense that the metapackage could be useful for dependency management.

qTHqq gravatar image qTHqq  ( 2021-01-15 09:12:38 -0500 )edit

Pkgs being "from the same company" is not sufficient rationale in most cases to put them in the same repository.

For sure, and I will consider that in my plans here. Now that I understand what a metapackage actually is and how it relates to folders on disk, I can move forward with planning that correctly.

I feel like the very first catkin tutorial could use a blinking red box that says "Each package is in a directory. We're going to make our packages directly in src but you could make it in src/nested/arbitrarily/deep/directory and catkin will still find and build it." I knew this years ago, but forgot it.

And I think it's just how CMake works, but I'm on Windows and usually work in Visual Studio. Obviously it's important to understand your tools but there's a lot to understand ...(more)

qTHqq gravatar image qTHqq  ( 2021-01-15 09:20:19 -0500 )edit

I don't see anything else after this line?

Yeah there's nothing else, I forgot to edit out "below." I was referring to the Autoware and MoveIt discussions I linked above that line.

qTHqq gravatar image qTHqq  ( 2021-01-15 09:23:38 -0500 )edit