What is a ROS 2 launch file?
ROS 2 launch files are powerful tools for launching multiple nodes, configuring parameters, remapping topic names, and controlling the execution of nodes in a complex robotic system. Launch files are extremely useful if your application has multiple nodes. It is not easy to run each node using the ros2 run
command, but launch files provide a way to run nodes with all their settings, and you can run these launch files with a single command.
The ros2 launch command is used to launch a launch file. Launch files are kept inside the ros 2 package. In ROS 2, the launch file can be written using Python, XML, and YAML. The Python launch file gives more flexibility compared to other options, especially in complex robotics applications. If you are writing the Python launch file, the extension will be *.py
, and usually a naming convention like *.launch.py
is followed.
The syntax of the ros2 launch
command is given below:
ros2 launch pkg_name launch_file_name...