IN THIS LESSON
You will learn how Launch Files work.
Launch files in ROS (Robot Operating System) are XML or Python scripts used to start multiple ROS nodes and configure parameters in a single command. They help automate and manage complex robotic systems by defining how different components should be launched and interact.
This is how you start the Launch Files.
In MiROS
All the Launch Files are listed in the Launch File table in the Mission Control view in MiROS. To launch one or multiple launch files, you need to connect to a robot or a simulated robot first by clicking to Connect to Robot button on the top right corner. Then you can click on the Launch button right to a Launch File to start the Launch File.
In Ubuntu (Linux)
Previously nodes were being launched and run individually from a new terminal for each node. However very quickly your systems will become more complex with multiple nodes running simultaneously, making sourcing and individually running each node a tedious task. Launch files are introduced to combat this problem. Launch files allow you to start up and configure a number of executables containing ROS2 noes simultaneously. The ‘ros2 launch’ command will start the entire system (nodes and their configurations) all at once.
Launch files are generally written in python but they can also be written in XML and YAML. To run a launch file the command is:
ros2 launch <package_name> <launch_file_name.py>
Launch files follow a specific structure with an example using turtlesim given below. More information is available online as to how to write launch files for your specific purpose.
# turtlesim/launch/multisim.launch.py
from launch import LaunchDescription
import launch_ros.actions
def generate_launch_description():
return LaunchDescription([
launch_ros.actions.Node(
namespace= "turtlesim1", package='turtlesim', executable='turtlesim_node', output='screen'),
launch_ros.actions.Node(
namespace= "turtlesim2", package='turtlesim', executable='turtlesim_node', output='screen'),
])
To launch the above file the following command must be run in a sourced terminal:
ros2 launch turtlesim multisim.launch.py
Launch File Table in Mission Control
-
For more in-depth tutorials and to learn about more advanced aspects of ROS, refer to the documentation at: https://docs.ros.org/en/humble/Tutorials.html