I’ve spent sometime working both with ROS1 and ROS2’s launch files and gotten somewhat comfortable with them. Is it me, or is writing launch file for ROS2 very awkward? My main source of complaint is that the Python-based launch file doesn’t seem to really leverage the advantage of Python. For example, instead of using the
if of the Python language, there’s a custom class called
IfCondition (see this question for confusion about this). Further, instead of being able to import another launch file, perhaps via something like
import (and then constructing an object, or call a function), we have
IncludeLaunchDescription. There are a lot of other examples of this as well. Having such custom construct, in my opinion, makes the resulting “code” extremely unpythonic. Common operations like trying to get the value of a configuration value is hidden behind very unintuitive methods like
LaunchConfiguration(...).perform(context), as opposed to something similar to the
argparse interface. For me, ROS2 launch files are almost like learning an entirely different language and it is made worse by the lack of documentation for some of these constructs. Others also appeared to have complained about this.
In fact, if you squint a bit, the existing system look basically exactly like XML, but written in Python: each action/object added to the
LaunchDescription can be represented by a XML node. While I haven’t tried this, I suspect that I can invent a XML format (probably quite similar to ROS1’s launchfile) that can be parsed by a Python program which then constructs a
LaunchDescription based on the parsed results. While the XML format has its own issues, I feel like writing XML in Python is significantly worse, as there are a lot of Python that I cannot easily access with this style of writing code.
It’s very possible that I’m just not “getting it”. So my question is: why is the ROS2 launch file designed the way it is? What is meant to be its strength and weakness? Is my assessment of it correct? I want to be wrong and learn its strengths so I can like it better, as I find the existing system to be a significant displeasure to work with.