Checking if ROS distro is newer than one specyfied in package.xml

There happen to be changes in packages names between distros. Generally, I would like to keep my package.xml exactly the same and change given dependencies based on ROS distro. Hence, my question is if it is possible to distinguish distro based on something else than string, for example integer like with ROS_VERSION environment variable.

My current idea is to use condition field in package.xml to determinate the distro. Normally, it would be syntax like:

<exec_depend condition="$ROS_DISTRO == foxy">robot_state_publisher</exec_depend>
<exec_depend condition="$ROS_DISTRO == galactic">robot_state_broadcaster</exec_depend>

But let’s assume I created my package in times of Galactic and then Humble was released. There is some probability I will forget to add another hard-coded option for Humble in future and this will break builds. Assuming those packages won’t be changed in the future, it would be nice to use syntax such as:

<exec_depend condition="$ROS_DISTRO <= foxy">robot_state_publisher</exec_depend>
<exec_depend condition="$ROS_DISTRO >= galactic">robot_state_broadcaster</exec_depend>

The main problem is, that it is string-based comparison. Is there a way to check ROS distro as a numerical value?

Best regards,
Krzysztof Wojciechowski.

The string-based comparison should be okay. That’s why the release names are given in alphabetic order. (What would happen when distros reach R, actually? Where would rolling go?)

Also, be sure to htmlencode the comparisons to &gt; and &lt; to keep it a valid XML document.

Ok. Fair point with Rolling. But since it is always the newest distro, it can be just a really big number, implying that we will never reach that many ROS distros.

I also used >= for comparison, since it is stated as an available operator in REP 149. But your point is valid.