The launch file

The launch file is a useful feature in ROS for launching more than one node. In these sections, we have created nodes and we have been executing them in different shells. Imagine working with 20 nodes and the nightmare of executing each one in a shell!

With the launch file, we can do it in the same shell by launching a configuration file with the extension .launch.

To practise using this utility, we are going to create a new folder in our package as follows:

    $ roscd chapter2_tutorials/
    $ mkdir launch
    $ cd launch
    $ vim chapter2.launch  

Now put the following code inside the chapter2.launch file:

<?xml version="1.0"?> 
  <node name ="example1_a" pkg="chapter2_tutorials"  type="example1_a"/> <node name ="example1_b" pkg="chapter2_tutorials" ...

Get ROS Programming: Building Powerful Robots now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.