Over the years, I’ve learned how to make ROS launch files do a number of…let’s say, unorthodox… things. As I’ve progressed my ROS 2 skill set, I’ve had to figure out how to recreate those behaviors, but that’s required translating them from XML to Python. (That’s one of the reasons why porting MoveIt Setup Assistant took so long)
The repository above contains ten common launch tasks, and how to code them in both ROS 1 XML and ROS 2 Python.
Launching a single node
Setting a parameter directly
Loading parameters from a launch file
Loading parameters from a command
Setting arguments via command line
Using substitutions
Including another launch file
Conditionals
Dynamic filenames
Making a node required
It’s for my own reference, but I figured it may also be useful to others as a way to translate launch files.
Note: It’s hosted on GitHub for two reasons. 1) It would be awkward to split it between the ROS 1 and ROS 2 wiki. 2) In my experience, the stewards of the ROS 2 wiki follow a let the past die philosophy to putting ROS 1 content on the new wiki.
I also see a dead link, and there doesn’t seem to be a repo by a similar name under that user. Perhaps it’s a repository that was private for development and hasn’t yet been made public?
Thanks for creating this documentation! It was also my experience that there is little information on how to create launch files…
Just thought I’d mention it, but you are missing an important way to get the package share directory, the substitutions.FindPackageShare defined in launch_ros . The main advantage of this method is that:
The package name can be dynamic (e.g. a command line argument)
Since it’s a substitution, you can easily concatenate with other substitutions / text without resorting to os.path.join. For example urdf_path = (FindPackageShare("my-package"), "urdf", LaunchConfiguration("robot_name"), ".urdf").