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.
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.
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").