yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
RDK S600 Developer Kit📖
1.RDK S600 board introduction
  • 1.1 RDK S600 board introduction
  • 1.2 System Flashing
  • 1.3 Hardware Interface Description
  • 1.4 Accessory Installation
  • 1.5 Camera Expansion Board
  • 1.6 MCU Interface Expansion Board
  • 1.7 Precautions for Using the 15.6-inch Screen
  • 1.8 System Boot Modes
2.RDK S600 basic course
  • 2.1 Network Configuration
  • 2.2 Remote Login
  • 2.3 System Update
  • 2.4 Boot Auto-Start Configuration
  • 2.5 RDK Exclusive Command Usage
  • 2.6 Linux Command Usage
  • 2.7 Examples of GPIO Read and Write Operations
  • 2.8 Using the USB Camera
  • 2.9 Solid-state mounting
  • 2.10 SSD expansionnew
3.TogetheROS.Bot Vision Applications
  • 1. About TogetheROS. Bot
  • 2. System Installation
  • 3. Object Detection(YOLO)
  • 4. Image Classification(mobilenetv2)
  • 5. Image Segmentation(mobilenet_unet)
  • 6. Perception Algorithm(BEV)
  • 7. Human Detection and Tracking (Ultralytics YOLO Pose)
4. Offline AI Large Model Development
Offline large model (Text Interaction)
  • 1. AI large model environment deployment
  • 2. Install large model dialogue platform
  • 3. Meta AI Llama 3.2 model
  • 4. Alibaba Cloud Qwen3 model
  • 5. Microsoft Phi-4 mini model
  • 6. DeepSeek - DeepSeek-R1 model
  • 7. Alibaba Cloud Qwen2.5vl Visual Multimodal Large Model
  • 8. Google Gemma3 Visual Multimodal Large Model
  • 9. Lava Visual Multimodal Large Model
  • 10. MiniCPM-V Visual Multimodal Large Model
  • 11. Multimodal visual understand application
  • 12. Multimodal text image application
  • 13. Multimodal visual localization application
  • 14. Multimodal table scanning application
  • 15. Multimodal Autonomous Agent Applications
Offline large model (Voice Interaction)
  • 0. Voice Interaction Hardware Connection (Must Read)
  • 1. Offline speech-to-text (ASR)
  • 2. Offline Text-to-Speech (TTS)
  • 3. AI large model voice interaction
  • 4. Multimodal visual understanding voice interaction
  • 5. Multimodal Text-to-Image application
  • 6. Multimodal video analytics application
  • 7. Multimodal visual localization application
  • 8. Multimodal table scanning application
  • 9. Multimodal autonomous agent application
  • 10. AI Large Model Offline Voice Assistant
5. Online AI Large Model Development
Online large model (Text Interaction)
  • 1.OpenRouter large model API aggregation platform
  • 2.Multimodal visual understand application
  • 3.Multimodal visual localization application
  • 4.Multimodal table scanning application
  • 5.Multimodal autonomous proxy application
Online large model (Voice Interaction)
  • 0.Voice interaction hardware connection (ReadMe)
  • 1.Online speech to text (ASR)
  • 2.Online text to speech (TTS)
  • 3.AI large model voice interaction
  • 4.Multimodal visual understand speech interaction
  • 5.Multimodal visual localization application
  • 6.Multimodal table scanning application
  • 7.Multimodal autonomous proxy application
  • 8.AI large model online voice assistant
6.YOLO26 tutorials
  • 01.YOLO26 environment
  • 02.CLI use
  • 03.Object detection
  • 04.Instance segmentation
  • 05.Pose estimation
  • 06.Image classification
  • 07.Oriented object detection
  • 08.Model conversion
  • 09.Dataset annotation
  • 10.Model training - conversion
  • 11.Model prediction
7.OpenClaw Advanced Development
  • 1. OpenClaw Deployment
  • 2. OpenClaw and WhatsApp Plugin Application
  • 3. OpenClaw TUI Interaction
  • 4. OpenClaw WebChat Interaction
  • 5. OpenClaw Gate Gateway Operation Manual
  • 6. OpenClaw Plugin Function Introduction
  • 7. OpenClaw Tools Introduction
  • 8. OpenClaw ClawHub Introduction (skill Installation)
  • 9.OpenClaw Application - File Management
  • 10.OpenClaw Application - Browser Control
  • 11.OpenClaw Application - Camera
  • 12.OpenClaw Application - Script Execution
  • 13.OpenClaw Application - AI Programming (Peripheral & GPIO Control)
  • 14. OpenClaw Application - Dedicated AI Assistant
  • 15. OpenClaw Configure Web Search Capability
8.ROS2 basic course
  • 1.Introduction to ROS2
  • 2.ROS2 install Jazzy
  • 3.ROS2 development environment
  • 4.ROS2 workspace
  • 5.ROS2 function package
  • 6.ROS2 node
  • 7.ROS2 topic communication
  • 8.ROS2 service communication
  • 9.ROS2 action communication
  • 10.ROS2 custom interface message
  • 11.ROS2 parameter service case
  • 12.ROS2 meta-function package
  • 13.ROS2 distributed communication
  • 14.ROS2 DDS
  • 15.ROS2 time related API
  • 16.ROS2 common command tools
  • 17.ROS2 rviz2 use
  • 18.ROS2 rqt toolbox
  • 19.ROS2 Launch startup file configuration
  • 20.ROS2 recording and playback tool
  • 21.ROS2 URDF model
  • 22.ROS2 Gazebo simulation platform
  • 23.ROS2 TF2 coordinate transformation
Download
  • System_File
  • Code
  • 3D_Model_File
  • Tools_Software
Download ZIP

Welcome to RDK S600 Developer Kit repository

19.ROS2 Launch startup file configuration

19. ROS2 Launch File Configuration

Note: The accompanying reference video uses the ROS Humble version, for reference only

1. Launch Introduction

So far, every time we run a ROS node, we need to open a new terminal and run a command. There are many nodes in a robot system, and it's troublesome to start them this way every time. Is there a way to start all nodes at once? The answer is definitely yes - that's the Launch file. It's a script for multi-node startup and configuration in the ROS system.

In ROS2, launch is used for multi-node startup and configuring program runtime parameters. ROS2 launch files support XML, YAML, and Python formats. This section uses Python format launch files as an example. Compared to the other two formats, Python format is more flexible:

  • Python has many function libraries that can be used in launch files;

  • ROS2 common launch features and specific launch features are written in Python, so you can access launch features that may not be exposed in XML and YAML;

When writing ROS2 launch files in Python, the main thing is to abstract each node, file, script, etc. into an action, and use a unified interface to start them.

 

References:

  • Launch system design document: ROS 2 Launch System Design Document

  • Launch official API documentation: Launch API Documentation (Updated with Official)

 

  • Preparation: Create a package to store program files:

ros2 pkg create learn_launch --build-type ament_python

 

2. Writing Launch for a Single Node

2.1. Create Launch File

Create a launch folder under the package, then create a [single_node_launch.py] file in the launch folder. Copy the following content to this file:

​x
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    node = Node(
        package='pkg_helloworld_py',
        executable='helloworld',
        output='screen'
    )
    return LaunchDescription([node])

image-20250905174633450

 

2.2. Configure setup.py File

Launch files are commonly named LaunchName_launch.py, where LaunchName is customizable and _launch.py is commonly considered fixed. You need to modify the setup.py file under the package. The modification is to add the launch path and files under it, so the build can generate executable .py files.

xxxxxxxxxx
#1. Import related header files
import os
from glob import glob

#2. In the data_files list, add the launch path and the launch.py file under the path
(os.path.join('share',package_name,'launch'),glob(os.path.join('launch','*launch.py')))

image-20231031114303641

 

2.3. Build Package

xxxxxxxxxx
colcon build --packages-select learn_launch

image-20250905174942260

 

2.4. Run Program

  • Refresh environment variables, then run the launch file:

xxxxxxxxxx
ros2 launch learn_launch single_node_launch.py

image-20250905175036003

2.5. Source Code Analysis

  1. Import related libraries:

xxxxxxxxxx
from launch import LaunchDescription
from launch_ros.actions import Node
  1. Define a function generate_launch_description that returns a launch_description:

xxxxxxxxxx
def generate_launch_description():
    node = Node(
        package='pkg_helloworld_py',
        executable='helloworld',
    )
    return LaunchDescription([node])

Define a variable node as the return value for node startup. Call the Node function with two important parameters, package and executable.

  • package: Represents the package, the name of the package.

  • executable: Represents the program to execute, the name of the executable program.

Finally, call LaunchDescription function with node parameter to execute and return.

xxxxxxxxxx
return LaunchDescription([node])

 

3. Writing Launch for Multiple Nodes

3.1. Create Launch File

Create a new [multi_node_launch.py] file and add the following content:

xxxxxxxxxx
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    publisher_node = Node(
        package='pkg_topic',
        executable='publisher_demo',
        output='screen'
    )
    subscriber_node = Node(
        package='pkg_topic',
        executable='subscriber_demo',
        output='screen'
    )
    return LaunchDescription([
        publisher_node,
        subscriber_node
    ])

 

3.2. Build Package

xxxxxxxxxx
colcon build --packages-select learn_launch

image-20250905174942260

 

3.3. Run Program

  • Refresh environment variables, then run the launch file:

xxxxxxxxxx
ros2 launch learn_launch multi_node_launch.py

image-20250905175250026

 

If the terminal doesn't print content, we can check which nodes are started to verify if startup was successful. Enter in the terminal:

xxxxxxxxxx
ros2 node list

image-20231031120049494

3.4. Source Code Analysis

It's roughly the same as simple_node_launch.py, just with one more node.

4. Topic Remapping Example

4.1. Create Launch File

Create a [remap_name_launch.py] file in the same directory as multi_node_launch.py and add the following content:

xxxxxxxxxx
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    publisher_node = Node(
        package='pkg_topic',
        executable='publisher_demo',
        output='screen',
        remappings=[("/topic_demo", "/topic_update")]
    )
    return LaunchDescription([
        publisher_node
    ])

 

4.2. Build Package

xxxxxxxxxx
colcon build --packages-select learn_launch

image-20250905174942260

 

4.3. Run Program

First, let's see what topic the publisher_demo node publishes before remapping:

xxxxxxxxxx
ros2 launch learn_launch multi_node_launch.py
ros2 topic list

image-20231031121230604

Here the topic is [/topic_demo]

  • Refresh environment variables again and run the program after topic remapping to see the changes:

 

xxxxxxxxxx
ros2 launch learn_launch remap_name_launch.py
ros2 topic list

image-20250905175613834

As shown above, the topic has been remapped to [/topic_update].

 

4.4. Source Code Analysis

The main addition is:

xxxxxxxxxx
remappings=[("/topic_demo", "/topic_update")]

This remaps the original /topic_demo topic to /topic_update.

 

5. Launch File Nesting - Include Another Launch File Example

5.1. Create Launch File

Create an [include_launch.py] file in the same directory as multi_node_launch.py and add the following content:

xxxxxxxxxx
from launch import LaunchDescription
from launch_ros.actions import Node
import os
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from ament_index_python.packages import get_package_share_directory

def generate_launch_description():
    hello_launch = IncludeLaunchDescription(PythonLaunchDescriptionSource(
        [os.path.join(get_package_share_directory('learn_launch'), 'launch'),
        '/multi_node_launch.py']),
    )
    return LaunchDescription([
        hello_launch
    ])

 

5.2. Build Package

xxxxxxxxxx
colcon build --packages-select learn_launch

image-20250905174942260

 

5.3. Run Program

  • Refresh environment variables and run the launch file:

xxxxxxxxxx
ros2 launch learn_launch include_launch.py

image-20250905180404738

 

5.4. Source Code Analysis

  • Nesting launch files requires using two classes from the launch system: IncludeLaunchDescription and PythonLaunchDescriptionSource

  • os.path.join(get_package_share_directory('learn_launch'): Get the location of the package, where 'learn_launch' is the package name;

  • 'launch'): Represents the folder where launch files are stored under the package;

  • /multi_node_launch.py': Represents the /multi_node_launch.py file under the package's launch folder.

 

6. Comprehensive Launch File Example

This example mainly demonstrates how to write complex launch files. The program functionality can be ignored.

6.1. Create Launch File

Create a [complex_launch.py] file in the same directory as multi_node_launch.py and add the following content:

xxxxxxxxxx
import os
from ament_index_python import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.actions import GroupAction
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration
from launch.substitutions import TextSubstitution
from launch_ros.actions import Node
from launch_ros.actions import PushRosNamespace


def generate_launch_description():

    # args that can be set from the command line or a default will be used
    background_r_launch_arg = DeclareLaunchArgument(
        "background_r", default_value=TextSubstitution(text="0")
    )
    background_g_launch_arg = DeclareLaunchArgument(
        "background_g", default_value=TextSubstitution(text="255")
    )
    background_b_launch_arg = DeclareLaunchArgument(
        "background_b", default_value=TextSubstitution(text="0")
    )
    chatter_ns_launch_arg = DeclareLaunchArgument(
        "chatter_ns", default_value=TextSubstitution(text="my/chatter/ns")
    )

    # include another launch file
    launch_include = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(
            os.path.join(
                get_package_share_directory('demo_nodes_cpp'),
                'launch/topics/talker_listener_launch.py'))
    )
    # include another launch file in the chatter_ns namespace
    launch_include_with_namespace = GroupAction(
        actions=[
            # push-ros-namespace to set namespace of included nodes
            PushRosNamespace(LaunchConfiguration('chatter_ns')),
            IncludeLaunchDescription(
                PythonLaunchDescriptionSource(
                    os.path.join(
                        get_package_share_directory('demo_nodes_cpp'),
                        'launch/topics/talker_listener_launch.py'))
            ),
        ]
    )

    # start a turtlesim_node in the turtlesim1 namespace
    turtlesim_node = Node(
            package='turtlesim',
            namespace='turtlesim1',
            executable='turtlesim_node',
            name='sim'
        )

    # start another turtlesim_node in the turtlesim2 namespace
    # and use args to set parameters
    turtlesim_node_with_parameters = Node(
            package='turtlesim',
            namespace='turtlesim2',
            executable='turtlesim_node',
            name='sim',
            parameters=[{
                "background_r": LaunchConfiguration('background_r'),
                "background_g": LaunchConfiguration('background_g'),
                "background_b": LaunchConfiguration('background_b'),
            }]
        )

    # perform remap so both turtles listen to the same command topic
    forward_turtlesim_commands_to_second_turtlesim_node = Node(
            package='turtlesim',
            executable='mimic',
            name='mimic',
            remappings=[
                ('/input/pose', '/turtlesim1/turtle1/pose'),
                ('/output/cmd_vel', '/turtlesim2/turtle1/cmd_vel'),
            ]
        )

    return LaunchDescription([
        background_r_launch_arg,
        background_g_launch_arg,
        background_b_launch_arg,
        chatter_ns_launch_arg,
        launch_include,
        launch_include_with_namespace,
        turtlesim_node,
        turtlesim_node_with_parameters,
        forward_turtlesim_commands_to_second_turtlesim_node,
    ])

 

6.2. Build Workspace

xxxxxxxxxx
colcon build --packages-select learn_launch

image-20250905174942260

 

6.3. Run Program

  • Refresh environment variables in the terminal and run the launch file:

xxxxxxxxxx
ros2 launch learn_launch complex_launch.py

Two turtles will appear on the host machine's VNC.

image-20250905181104164

 

  • Start the keyboard control node and add namespace (because we added namespace when starting nodes in the launch file):

xxxxxxxxxx
ros2 run turtlesim turtle_teleop_key --ros-args -r __ns:=/turtlesim1
  • Use arrow keys to control turtle 1's movement. Turtle 2 will completely mimic turtle 1's behavior.

image-20250902150215135

 

6.4. Program Description

The program mainly starts:

  1. demo_nodes_cpp's talker_listener node,

  2. talker_listener node with namespace,

  3. Turtle 1 with turtlesim1 as namespace,

  4. Turtle 2 with turtlesim2 as namespace,

  5. Perform remapping so both turtles listen to the same command topic.

7. XML Implementation

7.1. Create Launch File

Create a [complex_launch.xml] file in the same directory as complex_launch.py and add the following content:

xxxxxxxxxx
<launch>

    <!-- args that can be set from the command line or a default will be used -->
    <arg name="background_r" default="0"/>
    <arg name="background_g" default="255"/>
    <arg name="background_b" default="0"/>
    <arg name="chatter_ns" default="my/chatter/ns"/>

    <!-- include another launch file -->
    <include file="$(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.py"/>
    <!-- include another launch file in the chatter_ns namespace-->
    <group>
      <!-- push-ros-namespace to set namespace of included nodes -->
      <push-ros-namespace namespace="$(var chatter_ns)"/>
      <include file="$(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.py"/>
    </group>

    <!-- start a turtlesim_node in the turtlesim1 namespace -->
    <node pkg="turtlesim" exec="turtlesim_node" name="sim" namespace="turtlesim1"/>
    <!-- start another turtlesim_node in the turtlesim2 namespace
        and use args to set parameters -->
    <node pkg="turtlesim" exec="turtlesim_node" name="sim" namespace="turtlesim2">
      <param name="background_r" value="$(var background_r)"/>
      <param name="background_g" value="$(var background_g)"/>
      <param name="background_b" value="$(var background_b)"/>
    </node>
    <!-- perform remap so both turtles listen to the same command topic -->
    <node pkg="turtlesim" exec="mimic" name="mimic">
      <remap from="/input/pose" to="/turtlesim1/turtle1/pose"/>
      <remap from="/output/cmd_vel" to="/turtlesim2/turtle1/cmd_vel"/>
    </node>
</launch>

7.2. setup.py File Configuration

  • You need to configure the build file so that during build, our .xml format launch file is copied to the install directory, so the ROS system can find our file.

image-20250905182956976

 

7.3. Build Package

xxxxxxxxxx
colcon build --packages-select learn_launch

image-20250905174942260

 

7.4. Run Program

Enter in terminal:

xxxxxxxxxx
ros2 launch learn_launch complex_launch.xml
  • As expected, two turtles will appear and the terminal will print log information.

image-20250905181104164

  • Start the keyboard control node and add namespace:

xxxxxxxxxx
ros2 run turtlesim turtle_teleop_key --ros-args -r __ns:=/turtlesim1

Use keyboard to control and start turtle 1. Turtle 2 will completely mimic turtle 1's behavior.

 

8. YAML Implementation

8.1. Create Launch File

Create a [complex_launch.yaml] file in the same directory as complex_launch.py and add the following content:

xxxxxxxxxx
launch:

# args that can be set from the command line or a default will be used
- arg:
    name: "background_r"
    default: "0"
- arg:
    name: "background_g"
    default: "255"
- arg:
    name: "background_b"
    default: "0"
- arg:
    name: "chatter_ns"
    default: "my/chatter/ns"


# include another launch file
- include:
    file: "$(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.py"

# include another launch file in the chatter_ns namespace
- group:
    - push-ros-namespace:
        namespace: "$(var chatter_ns)"
    - include:
        file: "$(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.py"

# start a turtlesim_node in the turtlesim1 namespace
- node:
    pkg: "turtlesim"
    exec: "turtlesim_node"
    name: "sim"
    namespace: "turtlesim1"

# start another turtlesim_node in the turtlesim2 namespace and use args to set parameters
- node:
    pkg: "turtlesim"
    exec: "turtlesim_node"
    name: "sim"
    namespace: "turtlesim2"
    param:
    -
      name: "background_r"
      value: "$(var background_r)"
    -
      name: "background_g"
      value: "$(var background_g)"
    -
      name: "background_b"
      value: "$(var background_b)"

# perform remap so both turtles listen to the same command topic
- node:
    pkg: "turtlesim"
    exec: "mimic"
    name: "mimic"
    remap:
    -
        from: "/input/pose"
        to: "/turtlesim1/turtle1/pose"
    -
        from: "/output/cmd_vel"
        to: "/turtlesim2/turtle1/cmd_vel"

8.2. Configuration

  • You need to configure the build file so that during build, our .yaml format launch file is copied to the install directory, so the ROS system can find our file.

image-20250905183832452

 

8.3. Build Package

xxxxxxxxxx
colcon build --packages-select learn_launch

image-20250905174942260

8.4. Run Program

  • Refresh environment variables then run:

xxxxxxxxxx
ros2 launch learn_launch complex_launch.yaml
  • As expected, two turtles will appear and the terminal will print log information.

image-20250905181104164

  • Start the keyboard control node and add namespace:

xxxxxxxxxx
ros2 run turtlesim turtle_teleop_key --ros-args -r __ns:=/turtlesim1

Use keyboard to control and start turtle 1. Turtle 2 will completely mimic turtle 1's behavior.

ROS2 rqt toolbox
ROS2 recording and playback tool

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文