Note
You're reading the documentation for a development version. For the latest released version, please have a look at Lyrical.
Node management
Launch files help you start and configure multiple nodes in a ROS system without running each process manually. This article introduces the ROS launch system and explains how it uses launch files to describe, run, and manage system processes.
A ROS 2 system typically consists of many nodes running across many different processes (and even different machines). While it is possible to manually start each of these nodes, it gets cumbersome quite quickly.
The launch system in ROS 2 is meant to automate the running of many nodes with a single command. It helps the user describe the configuration of their system and then executes it as described. The configuration of the system includes what programs to run, where to run them, what arguments to pass them, and ROS-specific conventions which make it easy to reuse components throughout the system by giving them each a different configuration. It is also responsible for monitoring the state of the processes launched, and reporting and/or reacting to changes in the state of those processes.
All of the above is specified in a “launch file”, which can be written in XML, YAML, or Python.
This launch file can then be run using the ros2 launch command, and all of the nodes specified will be run.
To get started writing and using launch files, see the launch tutorials.
For more detailed information, see the launch documentation.
Shutting down
When ros2 launch gets SIGINT (e.g. from Ctrl+C) or SIGTERM, it shuts down all of the processes it started.
It does this by sending them SIGINT, then SIGTERM, and finally SIGKILL, each time waiting a few seconds for them to exit.
When you press Ctrl+C in a terminal, the terminal sends SIGINT to ros2 launch and to all of its processes at the same time, so ros2 launch does not send them another one.
This means that if something sends SIGINT to only the ros2 launch process, e.g. kill -INT <pid> from a script, then its processes will not start to shut down until they get SIGTERM a few seconds later.
To avoid this, send SIGTERM to ros2 launch instead, or pass --noninteractive to ros2 launch, which makes it always send SIGINT to its processes.
--noninteractive is the default when stdin is not a terminal.
For more details, see the launch signal handling documentation.