🤖
Introduction to ROS2 and Robotics
  • Introduction
  • ROS2
    • Index
    • IDE and CMake Setup
      • How to add additional include search path
    • ROS2 Building Blocks
      • ROS Workspace and Package Layout
      • Launch File
      • tf2
      • Quality of Service
      • Configurations
        • Rviz Configuration
      • Built-in Types
        • Built-in Message Type
    • ROS Architecture
      • Intra-process Communication
    • Navigation and Planning
      • Navigation Stack and Concepts
      • Navigation2 Implementation Overview
        • 🏗️Cost Map
        • Obstacle Avoidance and DWB Controller
      • DWB Controller
      • Page 5
    • How to launch the Nav2 stack
    • ROS2 Control
      • Online Resources
      • Overview of Codebase
    • 🍳Cookbook
      • Useful Commands
      • How to specify parameters
      • How to build the workspace
      • 🏗️How to publish message to a topic from command line?
      • How to inspect service and make a service call
      • How to properly terminate ROS and Gazebo
      • How to add and remove models in Gazebo simulation dynamically
      • 🚧How to spin nodes
    • 🛒Tutorials
      • Services and Communication between ROS2 and Gazebo
      • Subscription and Message Filters Demo
      • Executor and Spin Explained
      • Lifecycle Node Demo
      • Robotic Arm Demo
      • ⚒️Multiple Robotic Arms Simulation Demo
      • 🚧Introduction to xacro
    • Page
    • 🍺Tech Blog
      • Difference between URDF and SDF and how to convert
  • Gazebo
    • Index
    • Terminology
    • GUI
    • World Frame and Axis
    • Cookbook
    • Page 1
  • Programming in Robotics
    • C++
      • CMake
    • Python
    • Rust
  • Mathematics in Robotics
    • Linear Algebra
    • Matrix Properties
    • Probability
      • Expectation-Maximization Algorithm
    • Multivariable Function and Derivatives
  • Physics in Robotics
  • Control of Dynamic Systems
    • Dynamic Response and Transfer Function
    • Block Diagram
    • PID Controller
  • Robot Modeling and Control
    • Rotation and Homogeneous Transformation
  • Probabilistic Robotics
    • Bayes Filter
    • Kalman Filter
    • Particle Filter
    • Discrete Bayes Filter
    • Motion Model
    • Perception Model
    • Localization
    • SLAM
  • Miscellany
  • Concept Index
    • Quaternions
Powered by GitBook
On this page
  1. ROS2
  2. ROS2 Building Blocks

Launch File

PreviousROS Workspace and Package LayoutNexttf2

Last updated 1 year ago

Launch files are used to launch a large system with many executables where an executable may contain multiple nodes. From a computing perspective, nodes or executables form a graph because the philosophy of ROS2 is to have independent modules that focus on a single responsibility. The communication between nodes are supported through message passing. From a launch process perspective, the executables and launch files form a tree structure.

Suppose we have a main launch file for our project learn-launch-file. This launch file can launch nodes/executables of the project learn-launch-file and run launch files in other projects. A more concrete example is presented below:

The syntax are different for these two types of tasks. To launch a node, we use the Node class. For example:

from launch_ros.actions import Node
robot_state_publisher = Node(
    package="robot_state_publisher",
    executable="robot_state_publisher",
    name="my_robot_state_publisher",
    output="both",
    parameters=[
        {"use_sim_time": True},
        {"robot_description": robot_model_description},
    ]
)

rviz = Node(
    package="rviz2",
    executable="rviz2",
    condition=IfCondition(LaunchConfiguration("rviz")),
    arguments=["-d", path.join(bringup_package, "config", "slam_and_nav_v1.rviz")]
)

To run another launch file inside our current launch file, we use IncludeLaunchDescription and PythonLaunchDescriptionSource. For example:

from launch.actions import IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource

slam_toolbox = IncludeLaunchDescription(
    PythonLaunchDescriptionSource(path.join(get_package_share_directory("slam_toolbox"), "launch", "online_async_launch.py")),
    launch_arguments={
        'use_sim_time': "True",
        'slam_params_file': PathJoinSubstitution([bringup_package, "config", "mapper_params_online_async.yaml"])
    }.items(),
)

The parameters for specifying the arguments are different. Use arguments for a node and launch_arguments for a launch file.