by Helen Lin edited by Jeremy Huey
This guide shows you how to create launch files for your code so that you can launch multiple nodes at once rather than running each node individually.
Open a new terminal window and navigate to a package you want to create a launch file in. Create a folder called 'launch'.
mkdir launch
Navigate to the launch directory and create a new launch file ending in .launch. Replace 'name' with the name of your launch file.
touch name.launch
Add the following code and fill in the parameters within the double quotes.
Here is an example of what the node will look like filled in, using code from the Mini Scouter project:
The pkg name can be found in the package.xml. Eg.
Make sure you have run the following command on all of the files used in the launch file so they can all be found by ROS launch. Replace 'name' with the name of the python file.
chmod +x name.py
Change the permissions of the launch file as well by going to the launch directory and running the following command. Replace 'name' with the name of the launch file.
chmmod +x name.launch
Open a new terminal window and run the following command. Replace 'package_name' with the name of the package and 'name' with the name of the launch file.
roslaunch package_name name.launch
For example, to run the Mini Scouter launch file:
roslaunch mini_scouter teleop.launch
All of the nodes you specified in the launch file should now be running.
To have a node launch and open in a new window, such as to run things like key_publisher.py, you can modify the line to include this: <node pkg="object_sorter" type="key_publisher.py" name="key" output="screen" launch-prefix="xterm -e"/>
You must then run in terminal:
To continue to get more information on launch files, go to here: labnotebook/faq/launch-files.md