yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
Raspberry Pi 5📖
00.Quick Start (Must See)
  • 1.Quick Start (Must See)
  • 2.TF card expand capacity
  • 3.Raspberry Pi 5 - 1GB Version Must - See Before Use
01.Introduction to Raspberry PI 5
  • 1. Introduction to Raspberry PI 5
  • 2. Raspberry PI system installation and backup
  • 3. Powering the Raspberry PI 5
  • 4. Startup of Raspberry PI 5
  • 5. Installation and introduction of shell and active radiator
  • 6. GPIO and 40-pin pins
  • 7. Tips for using Raspberry PI 5
  • 8. Raspberry PI PCIe connector
  • 9. MIPI CSI DSI connector
  • 10. UART connector
  • 11. Real-time clock
  • 12. Power over Ethernet (PoE) connector
02.Introduction to common mirror systems
  • 1. Official Raspberry PI system
  • 2. Ubuntu
03.Basic settings of Raspberry Pi
  • 1. Update and upgrade operating system
  • 2.Introduction to raspi-config tool
  • 3.config.txt file description
  • 4.Network Configuration
  • 5.remote access
  • 6.Transfer files remotely
  • 7.Set display resolution and rotation
  • 8.Set screen to sleep
  • 9.Get real-time temperature of Raspberry Pi
  • 10.Play audio and video
  • 11.Using USB camera
  • 12.Using MIPI camera
04.Basic programming course
1. C language programming
  • 1. C language environment construction
  • 2. Print Hello World
2. Python programming
  • 1.Python usage
  • 2.Use APT to install Python packages
  • 3.Python virtual environment
  • 4.GPIO Zero
  • 5.Pin output high and low levels
  • 6.Pin reads high and low levels
  • 7.Pin output PWM
3.Jupyter lab programming
  • 1.Jupyter Lab environment construction
  • 2.Basic use of Jupyter Lab
  • 3.Jupyter Lab plug-in installation
  • 4.Basic use of Jupyter Widgets
05.Advanced AI course
5.Advanced AI gameplay
  • 1. Human pose estimation
  • 2. target detection
  • 3.yolov5
  • 4. Camera display
  • 5. QR code
  • 6. face detection
  • 7. Color recognition
2.Getting started with Open Source CV
  • 1. Introduction to Open Source CV
  • 2. Read and display Open Source CV images
  • 3. Open Source CV image writing
  • 4. Open Source CV image quality
  • 5.Open Source CV pixel operation
3.Open Source CV Geometric Transformations
  • 1. Image resizing
  • 2. Cut the image
  • 3. Image translation
  • 4. Image mirroring
  • 5. Affine transformation
  • 6. Rotate the image
  • 7. Perspective transformation
4.Text Picture Drawing Open Source CV image processing and drawing text line segments
  • 1、Grey Processing
  • 2、image binaryzation
  • 3、edge detection
  • 4、Line segment drawing
  • 5、Rectangle and circle drawing
  • 6、Text image drawing
1.Open Source CV environment setup
  • Open Source CV environment setup
6.YOLOv11 development
  • 1. YOLOv11 environment construction
  • 2. CLI Usage
  • 3. Object Detection
  • 4. Instance Segmentation
  • 5. Pose Estimation
  • 6. Image Classification
  • 7. Oriented Bounding Boxes Object Detection
  • 8. Model conversion
  • 9. Dataset Annotation
  • 10. Model training_conversion
  • 11. Model prediction
7.YOLO26 development
  • 01.YOLO26 environment
  • 02.CLI use
  • 03.Object detection
  • 04.Instance segmentation
  • 05.Pose estimation
  • 06.Image classification
  • 07.Oriented bounding box object detection
  • 08.Model conversion
  • 09.Dataset annotation
  • 10.Model training - conversion
  • 11.Model prediction
06.Mediapipe course
  • 1. Face special effects
  • 2. Face detection
  • 3. Three-dimensional object recognition
  • 4. Paintbrush
  • 5. Finger control
  • 6. Gesture recognition
07.Docker Tutorial
  • 1.Overview and installation
  • 2.Common commands
  • 3.Understand and publish images
  • 4.Hardware interaction data processing
  • 5.Enter docker container
  • 6.Update docker images
  • 7. docker container to install ROS using accessories
08.ROS1 advanced tutorial
1.ROS1 basic course
  • 1.ROS introduction
  • 2.ROS installation
  • 3.ROS common command tools
  • 4.ROS workspace
  • 5.ROS function package
  • 6.ROS node
  • 7.ROS topic publisher
  • 8.ROS topic subscribers
  • 9.ROS service client
  • 10.ROS service server
  • 11.ROS action client
  • 12.ROS action server
  • 13.ROS custom message reception
  • 14.ROS-launch file
  • 15.ROS-TF transformation
  • 16.ROS parameter service
  • 17.ROS-rviz use
  • 18.ROS-rqt tool usage
  • 19.Topic message recording and playback
  • 20.urdf model introduction
  • 21.gazebo introduction
  • 22.ROS distributed communication
2.ROS1 vision application
  • 0.Precautions
  • 1.AR vision
  • 2.AR QR code
  • 3.ROS+Opencv basics
  • 4.Face recognition
  • 5.harris corner detection
  • 6.Target tracking algorithm
  • 7.Contour moment
  • 8.Polygon outline
  • 9.Discrete fourier transform algorithm
  • 10.Edge detection algorithm
  • 11.Face detection algorithm
  • 12.Optical flow detection algorithm
  • 13.Contour detection
  • 14.General contour detection
  • 15.Feature point tracking
  • 16.HLS color filtering
  • 17.Hough circle detection
  • 18.Hough linear detection
  • 19.HSV color filtering
  • 20.LK optical flow algorithm
  • 21.detection algorithm
  • 22.Phase dependent displacement detection
  • 23.Image pyramid sampling algorithm
  • 24.RGB color filtering
  • 25.Clear background detection algorithm
  • 26.Simplified optical flow algorithm
  • 27.Simple filter
  • 28.Threshold image processing
  • 29.Watershed segmentation algorithm
09.ROS2 advanced tutorial
1.ROS2 basic course
  • 1. Introduction to ROS2
  • 2.ROS2 install Humble
  • 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
2.ROS2 vision application
  • 0.Precautions
  • 1.Opencv basic course
  • 2.ROS+opencv application
  • 3.QR code creation and recognition
  • 4.AR vision
  • 5.Interesting gameplay of mediapipe
10.Offline AI model coursenew
Offline large model (Text Interaction)
  • 0. AI large model image description
  • 1. Deployment of large AI model environments
  • 2. Switch Chinese input method
  • 3. Installation of large model dialogue platform
  • 4. Meta AI Llama 3.2 model
  • 5. Alibaba Cloud Qwen3 Model
  • 6. Microsoft Phi-4-mini model
  • 7. DeepSeek DeepSeek-R1 model
  • 8. Alibaba Cloud Qwen2.5vl Visual Multimodal Large Model
  • 9. Google Gemma3 Visual Multimodal Large Model
  • 10. Llava Visual Multimodal Large Model
  • 11.MiniCPM-V Visual Multimodal Large Model
  • 12. Multimodal Visual Understanding Applications
  • 13. Multimodal Text-Based Image Application
  • 14. Multimodal Video Analysis Application
  • 15. Multimodal visual positioning applications
  • 16. Multimodal table scanning application
  • 17. Multimodal Autonomous Agent Application
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 and voice interaction
  • 5. Multimodal Text-Based Image Application
  • 6. Multimodal Video Analysis Application
  • 7. Multimodal visual positioning applications
  • 8. Multimodal table scanning application
  • 9. Multimodal Autonomous Agent Applications
  • 10. AI large model offline voice assistant
11.Online AI model coursenew
Online large model (text interaction)
  • 1.OpenRouter Large Model API Aggregation Platform
  • 2. Multimodal Visual Understanding Applications
  • 3. Multimodal visual positioning applications
  • 4. Multimodal table scanning application
  • 5. Multimodal Autonomous Agent Applications
Online large model (voice interaction)
  • 0. Voice Interaction Hardware Connection (Must Read)
  • 1. Online speech-to-text (ASR)
  • 2. Online Text-to-Speech (TTS)
  • 3. AI large model voice interaction
  • 4. Multimodal visual and voice interaction
  • 5. Multimodal visual positioning applications
  • 6. Multimodal table scanning application
  • 7. Multimodal Autonomous Agent Applications
  • 8. AI large model online voice assistant
12.OpenClaw Deployment and Basic Usagenew
  • 01. OpenClaw Deployment
  • 02. OpenClaw WhatsApp Plugin Application
  • 03. OpenClaw WebChat Interaction
  • 04. OpenClaw TUI Interaction
  • 05. OpenClaw Tools Introduction
  • 06. OpenClawGate Gateway User Manual
  • 07. OpenClaw Features Overview
  • 08. OpenClawHub Introduction (Skill Installation)
  • 09. OpenClaw Application - File Management
  • 10. OpenClaw Application - Camera
  • 11. OpenClaw Application - Browser Control
  • 12. OpenClaw Application - Script Execution
  • 13. OpenClaw Application - AI Programming (Peripheral & GPIO Control)
  • 14. OpenClaw Application - Dedicated AI Assistant
13.OpenClaw Advanced Developmentnew
1.Preparation Before Use
  • 01. Peripheral Hardware Configuration
  • 02. OpenClaw API-KEY Configuration
  • 03. OpenClaw Model Switching
  • 04. OpenClaw Prompts
  • 05. AI Voice Interaction Configuration
  • 06. 3D Configuration Tests
2.OpenClaw AI Programming Peripheral Control
  • 1. Servo Control
  • 2. RGB Strip
  • 3. OLED Display
  • 4. Temperature and Humidity Sensor
  • 5. Camera Application
  • 6. AI Script Peripheral Control
3.OpenClaw Peripheral Integration Applications
  • 1. Plant Care Assistant
  • 2. AI Calorie Estimation
  • 3. AI Rock Paper Scissors Game
  • 4. AI Pet
  • 5. AI Weather Station
  • 6. Temperature and Humidity Dashboard
  • 7. Scheduled Tasks
Download
  • SystemFile
  • Code
  • SoftWare
  • 3D_Model_File
  • GuideManual
Download ZIP

Welcome to Raspberry Pi 5 repository

14.ROS-launch file

14.ROS-launch file

14.ROS-launch file

This course will explain the commonly used launch files in the ros system, talk about the concept of launch files and how to write launch files.

14.1 launch file

The launch file is a file provided by ROS for starting multiple nodes. The format is XML format. It can make the process of starting multiple ROS nodes simple. It also simplifies the process of parameter setting by the ROS parameter server.The file name ends with .launch. As mentioned before, generally, we will create a folder named launch under the path of the function package to store the delaunch files belonging to the function package.

14.1.1 roslaunch

Run the launch file. ROS provides the roslaunch tool. Unlike rosrun, roslaunch can start multiple nodes at the same time. You only need to write multiple nodes into the running launch file. The command to start roslaunch is as follows, enter in the terminal,

roslaunch <pkg_name> <launch_file_name>

pkg_name: represents the name of the function package. According to the actual situation, change it to the name of the function package where the launch file is located;

launch_file_name: Indicates the file name of the launch file that needs to be launched.

14.2 Write launch file

14.2.1 Launch file of a single node

The format of the launch file is in XML format, and it needs to have a root element. The root element of the launch file is a pair of , and appears at the beginning of the launch file. appears at the end of launch,

xxxxxxxxxx
<launch>
...
...
</launch>

The launch file starts the node program, so the core is one or more nodes. Each node represents the started node program. A node startup must include the following points:

  • pkg: the name of the function package where the node is located
  • type: the name of the executable program running the node
  • name: The name of the node does not have to be the same as the name of the node defined in the program, it can be named arbitrarily

A necessary node element in the launch file has the following format:

xxxxxxxxxx
<node pkg="pkg_name" type="excutable_name" name="node_name"/>

Note that the last / is essential, of course, you can also write,

xxxxxxxxxx
<node 
    pkg="pkg_name" type="excutable_name" name="node_name">
</node>

We use the following command to create a function named learn_launch in the ros_ws/src directory and enter it in the terminal,

xxxxxxxxxx
cd ~/ros_ws/src/
catkin_create_pkg learn_launch std_msgs rospy roscpp

image-20231024114413619

Then in the learn_launch directory, create a new folder named launch and enter in the terminal,

xxxxxxxxxx
cd ~/ros_ws/src/learn_launch
mkdir launch

Go back to the workspace directory to compile,

xxxxxxxxxx
cd ~/ros_ws
catkin_make

Then create a new file in the launch folder, the file name is turtle_node.launch, and put the following content into it,

xxxxxxxxxx
<launch>
    <node pkg="turtlesim" type="turtlesim_node" name="turtle"/>  
</launch>

Exit after saving, then run the launch file and enter in the terminal,

xxxxxxxxxx
roslaunch learn_launch turtle_node.launch

image-20231024115704156

As shown in the picture above, after launch is run, roscore will be automatically turned on, and then the baby turtle program will be run to generate a baby turtle.

14.2.2 Launch files of multiple nodes

We write a launch file. This launch file starts two nodes, one is the node that generates the little turtle, and the other is the node that runs the keyboard to control the little turtle. In the launch folder, create a new file named turtle_ctrl.launch and copy the following content into it,

xxxxxxxxxx
roslaunch learn_launch turtle_ctrl.launch

image-20231024121142486

After running, click on the terminal interface and press the up, down, left and right keys on the keyboard to control the movement of the turtle. We can use the rosnode list command to see which nodes are currently running, and enter in the terminal,

xxxxxxxxxx
rosnode list

image-20231024121349919

/turtle and /turtle_ctrl are the corresponding turtle nodes and control nodes, and the corresponding names are the value of node's name in the launch file code.

14.2.3 Load and run the launch file in the launch file

In the launch file, you can not only run the node, but also load and run the launch file, that is, nested use. The tag needed here is . The commonly used format is,

xxxxxxxxxx
<include file=”$(find package_name)/launch/launch_file_name”/>

package_name: Indicates the function package where the launch file is located

launch_file_name: Indicates the file name of the launch file that needs to be run.

We create a new file and name it listen_turtle_pose.launch. This program implements the following functions: after the program is run, a small turtle will be generated, and the terminal will print out the xy coordinates of the small turtle;Click on the terminal, we control the little turtle through keyboard control, and when the little turtle moves, the terminal will print out the xy coordinates of the little turtle in real time. Copy and paste the following content into the listen_turtle_pose.launch file,

xxxxxxxxxx
<launch>
    <include file="$(find learn_launch)/launch/turtle_ctrl.launch"/>
    <node pkg="learn_topic" type="turtle_pose_subscriber" name="turtle_pose" output="screen"/>  
</launch>

Here, a parameter output is added when node is started, because we want to print this information on the terminal.So it is output to the screen screen and there are two values: log is output to the log, and none has no output.

image-20231024140845875

14.2.4 launch file loading parameters

In the launch file, there are two variables representing parameters, namely arg and param. Their meanings are as follows:

  • arg

    Used for parameterized parameters, different parameter values can be passed in at startup, including the following two parts:

    • name:the name of the parameter
    • default:the default value of the parameter

    When used, the format is as follows:

    xxxxxxxxxx
    <arg name="arg_name" default="default_value"/>
  • param

    Used to set parameters in the parameter server (Parameter Server), including the following two parts:

    • name:the name of the parameter
    • value:the value of the parameter

    When used, the format is as follows:

    xxxxxxxxxx
    <param name="parameter_name" value="parameter_value"/>

Summary: arg is used in the launch file and can be flexibly configured. The value of arg can be used as the value of param; param is used in the parameter server of the node, that is, used in the node program. The parameter server will be mentioned in the following tutorials.

To give an example of how to use these two, create a launch file in the launch folder and name it set_backgroud_color.launch.After this program is started, the color of the background plate that generates the little turtle will be modified according to the parameters we set. Copy the following content to the set_backgroud_color.launch file,

xxxxxxxxxx
<launch>
    <arg name="r_value" default="100"/>
    <arg name="g_value" default="0"/>
    <arg name="b_value" default="100"/>
    <node pkg="turtlesim" type="turtlesim_node" name="turtle">
        <param name="/background_r" value="$(arg r_value)"/>  
        <param name="/background_g" value="$(arg g_value)"/> 
        <param name="/background_b" value="$(arg b_value)"/> 
    </node>
</launch> 

Save and exit, then enter in the terminal,

xxxxxxxxxx
roslaunch learn_launch set_backgroud_color.launch

image-20231024144835497

The color of the background plate becomes the color with the rgb value we set as (100, 0, 100). We can also modify the rgb value on the command line during startup, as long as we bring parameters, for example, terminal input,

xxxxxxxxxx
roslaunch learn_launch set_backgroud_color.launch b_value:=2

image-20231024145105126

It can be seen that when we start the command, we change the value of b_value to 2 and then pass it in. How are the parameters passed here? In the node tag, we set three parameters, namely /background_r, /background_g and /background_b. Their value values are $(arg r_value), $(arg g_value) and $(arg b_value) respectively;Let’s look at the default values of r_value, g_value and b_value, which are 100, 0 and 100 respectively in the arg tag above. This is very clear: We define the value in arg, and then pass the value defined in arg to the value in param.Just add $(arg g_value) when quoting. Of course, you don’t have to, that is, write In this case, the parameter value of /background_g is fixed at 255.

14.2.5 Launch file remaps topic name

In the actual development process, the original preset topic names often need to be modified based on the topic names of other nodes. Source code modification is troublesome. The C++ version of the code still needs to be compiled after modification, which is more troublesome.But in the launch file, you can use the tag to remap the topic name and map the preset topic name to other ones. The usage is as follows:

xxxxxxxxxx
<remap from="original_topic" to="remapped_topic" />

original_topic: the topic name set in the original node program

remapped_topic: mapped topic name

Here is an example of how to use the tag. Create a new file in the launch folder and name it remap_topic.launch. After the program is run, the speed control topic name of the little turtle will be changed to the set topic name.Let’s take a look at what the original one is. First start the little turtle and enter it in the terminal.

xxxxxxxxxx
roslaunch learn_launch turtle_node.launch

After running successfully, enter rostopic list to see, enter in the terminal,

xxxxxxxxxx
rostopic list

image-20231024153247086

The speed control topic at this time is /turtle1/cmd_vel, paste the following code into remap_topic.launch,

xxxxxxxxxx
<launch>
    <node pkg="turtlesim" type="turtlesim_node" name="turtle">
        <remap from="/turtle1/cmd_vel" to="/ctrl_vel"/>
    </node>  
</launch>

Exit after saving, close the original Little Turtle launch, and enter in the terminal,

xxxxxxxxxx
roslaunch learn_launch remap_topic.launch

After running successfully, enter rostopic list to see, enter in the terminal,

xxxxxxxxxx
rostopic list

image-20231024154251011

At this time, the original /turtle1/cmd_vel is gone and mapped to /ctrl_vel. This is because we remapped the topic in the launch file.

xxxxxxxxxx
<remap from="/turtle1/cmd_vel" to="/ctrl_vel"/>

14.2.6. Use conditional statements in launch files

In the launch file, we can add conditional judgment to select the node program to start. The conditional judgment is controlled by if and unless in the launch file. Specific usage examples are as follows:Create a new file in the launch folder and name it condition_ctrl_turtle.launch. After the program is run, based on the actual parameters, determine whether to start the keyboard control node to control the turtle. Copy the following content to condition_ctrl_turtle.launch.

xxxxxxxxxx
<launch>
    <arg name="ctrl_node" default="true"/>
    <node pkg="turtlesim" type="turtlesim_node" name="turtle"/>  
    <node pkg="turtlesim" type="turtle_teleop_key" name="turtle_ctrl" if="$(eval arg('ctrl_node') == true)"/>
</launch>

After saving, exit and enter the following command to run,

xxxxxxxxxx
roslaunch learn_launch condition_ctrl_turtle.launch

After the program is running, we enter rosnode list to see which nodes are started.

xxxxxxxxxx
rosnode list

image-20231024163418844

As you can see, we have started the control node of the little turtle. If we click on the launch terminal, we can use up, down, left, and right to control the movement of the little turtle. Let's try setting the parameter ctrl_node to false, close the launched launch file, and enter in the terminal,

xxxxxxxxxx
roslaunch learn_launch condition_ctrl_turtle.launch ctrl_node:=false

After the program is running, we enter rosnode list to see which nodes are started.

xxxxxxxxxx
rosnode list

image-20231024163828575

The query found that the control node is not running, because the if judgment is that the keyboard control program is started when the parameter ctrl_node is true.

xxxxxxxxxx
<node pkg="turtlesim" type="turtle_teleop_key" name="turtle_ctrl" if="$(eval arg('ctrl_node') == true)"/>

The judgment inside if is true, and the judgment inside unless is false

14.2.7 Using namespace in launch file

There is a concept of group in the launch file, the label is , which can organize the specified node nodes and put several nodes into the same namespace. Namespace is a namespace, which is used to avoid name conflicts. The same node name is not allowed in the ros system. For example, if we want to open two little turtle nodes in a terminal, if there is no namespace and we start them directly, conflicts will occur and the program will exit. Therefore, we need to add the command space namespace to the launch file. , which is equivalent to adding another identifier before the same node to distinguish the two nodes.

In the group, add the namespece parameter, which means that the namespace is added in front of all nodes in the group. The format used is as follows:

xxxxxxxxxx
<group ns="namespace">
 
<node pkg=".." .../>
 
</group>

Change the namespace to custom content. For example, create a new launch file under the launch file and name it group_turtle.launch. Copy the following content to group_turtle.launch.

xxxxxxxxxx
<launch>
    <group ns="robot1">
        <node pkg="turtlesim" type="turtlesim_node" name="turtle"/>  
    </group>
    <group ns="robot2">
        <node pkg="turtlesim" type="turtlesim_node" name="turtle"/>  
    </group>
</launch>

Save and exit. After the program runs, two windows will open and two turtles will be generated respectively.

image-20231024172631031

Enter rosnode list to query the currently running node information.

xxxxxxxxxx
rosnode list

image-20231024172812732

The query found that the nodes with two little turtles are /robot1/turtle and /robot2/turtle. The names of these two nodes are preceded by /robot1 and /robot2 respectively to distinguish the two nodes.Let's take a look at the topic again and enter rostopic list to query the current topic.

ROS custom message reception
ROS-TF transformation

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
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文