Creating a Python launch file – XML or Python for launch files?
There are actually three languages you can use to create launch files in ROS 2: Python, XML, and YAML. I will not cover YAML launch files as they are not seldom used, and YAML doesn’t have any competitive advantage over XML for launch files. Here, we will be focusing on Python and XML.
We will start this section by creating a Python launch file (the same application as before). Then, I will compare XML and Python launch files and give you some guidance on how to get the best out of them both.
Writing a Python launch file
As we already have a fully configured my_robot_bringup
package for our application, there’s no need to do anything else. All we have to do is create a new file inside the launch
directory.
For Python launch files, you will use the .launch.py
extension. Create a new file named number_app.launch.py
. Here is the code required to start the number_publisher
and number_counter...