官术网_书友最值得收藏!

Understanding the ROS launch file

In previous sections, we created nodes and have been executing them in different shells. Imagine working with 20 nodes and the nightmare of executing each one in a shell! However, with the launch file, we can do it in the same shell by launching a configuration file with the extension .launch. The launch file is a useful feature in ROS for launching more than one node.

To learn about the ROS launch file, we will create a new folder in the chapter2_tutorials package, as follows:

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

Add the following code inside the chapter2.launch file:

<?xml version="1.0"?> 
<launch> 
   <node name ="example1a" pkg="chapter2_tutorials" type="example1a" output="screen"/> 
   <node name ="example1b" pkg="chapter2_tutorials" type="example1b" output="screen"/> 
</launch> 

This file is simple, although we would have to write a very complex file to, for example, control a complete robot, such as PR2. These could be real robots or simulated in ROS.

The ROS launch is an XML file with the .launch extension and has a launch tag. Inside this tag, we will find the node tag, which is used to launch a node from a package, for example, the example1a node from the chapter2_tutorials package.

The chapter2.launch file will execute two nodes—the first two examples of this chapter :example1a and example1b.

To launch the file, use the following command:

 $ roslaunch chapter2_tutorials chapter2.launch

We will see something similar to the following screenshot on our screens:

ROS launch

The running nodes are listed in the screenshot. When you launch a launch file, it is not necessary to execute it before the roscore command; roslaunch does it for us.

主站蜘蛛池模板: 苗栗县| 唐山市| 丹东市| 灵台县| 介休市| 哈尔滨市| 漳浦县| 进贤县| 耒阳市| 雷波县| 万宁市| 浦东新区| 屯留县| 乡宁县| 日土县| 新田县| 康保县| 甘孜| 宜良县| 宣恩县| 普兰店市| 邹平县| 连山| 个旧市| 彭泽县| 建宁县| 墨脱县| 滦南县| 林甸县| 来凤县| 永州市| 麻江县| 马公市| 黑龙江省| 兴安县| 象州县| 桃江县| 依兰县| 本溪市| 涡阳县| 弋阳县|