- Robot Operating System Cookbook
- Kumar Bipin
- 261字
- 2021-06-18 19:20:57
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.
- Mastering Visual Studio 2017
- C語言程序設計案例教程(第2版)
- SQL Server 2016從入門到精通(視頻教學超值版)
- Cassandra Data Modeling and Analysis
- Visual Basic學習手冊
- Java EE 7 Performance Tuning and Optimization
- Building Microservices with .NET Core
- 軟件測試綜合技術
- R Data Science Essentials
- 從程序員角度學習數據庫技術(藍橋杯軟件大賽培訓教材-Java方向)
- Scala編程實戰
- Practical GIS
- OpenCV Android Programming By Example
- 深度實踐KVM:核心技術、管理運維、性能優化與項目實施
- 數據分析與挖掘算法:Python實戰