ROS2

ROS Launch

A launch file in ROS enables you to boot up multiple ROS nodes using a single node. This is how you can bring up all the nodes required, instead of trying to manually bring up every individual node.

Launch Configurations

You can use these 2 things to configure your launch files:

  • DeclareLaunchArgument
  • LaunchConfiguration

Resources

From their website:

  • LaunchConfiguration substitutions allow us to acquire the value of the launch argument in any part of the launch description.
  • DeclareLaunchArgument is used to define the launch argument that can be passed from the above launch file or from the console.

So what is the difference? LaunchArguments: Allow users to specify parameters at runtime from the command line when invoking the launch file.
LaunchConfiguration: Serve as internal variables within a launch file for better organization and reusability. They are useful for setting parameters that don’t change frequently.

So launch configurations are “internal”, and allows you to call others.

Example launch files, from https://docs.ros.org/en/humble/Tutorials/Intermediate/Launch/Creating-Launch-Files.html

from launch import LaunchDescription
from launch_ros.actions import Node
 
def generate_launch_description():
    return LaunchDescription([
        Node(
            package='turtlesim',
            namespace='turtlesim1',
            executable='turtlesim_node',
            name='sim'
        ),
        Node(
            package='turtlesim',
            namespace='turtlesim2',
            executable='turtlesim_node',
            name='sim'
        ),
        Node(
            package='turtlesim',
            executable='mimic',
            name='mimic',
            remappings=[
                ('/input/pose', '/turtlesim1/turtle1/pose'),
                ('/output/cmd_vel', '/turtlesim2/turtle1/cmd_vel'),
            ]
        )
    ])

Launch File ROS Composition

Some really cool things is that we use ComposableNodeContainer or LoadComposableNode, where we specify a target container

If you look at https://github.com/NVIDIA-ISAAC-ROS/nova_carter/blob/main/carter_navigation/launch/nav2.launch.py, we have the following:

  carter_container = Node(
      name='carter_container',
      package='rclcpp_components',
      executable='component_container_isolated',
      parameters=[params_file],
      output='screen')
  • This is the target_container. Also try using component_container_mt, which is multithreaded. I don’t know why we use the isolated one here, which isn’t multithreaded
def generate_launch_description():
    hesai_node = ComposableNode(
        package='isaac_ros_hesai',
        plugin='nvidia::isaac_ros::hesai::HesaiNode',
        name='hesai')
 
    pointcloud_to_flatscan_node = ComposableNode(...)
    flatscan_to_laserscan_node = ComposableNode(...)
 
    load_hesai_pipeline = LoadComposableNodes(
        target_container='carter_container',
        composable_node_descriptions=[
            hesai_node,
            pointcloud_to_flatscan_node,
            flatscan_to_laserscan_node
        ]
    )
 
    return LaunchDescription([load_hesai_pipeline])

No executables are specified

Notice that we don’t specify the executable, only the plugin. This is different from how you launch basic nodes.