当前位置:网站首页>ROS基础 - 使用 launch 文件(一) - 批量启动多个ROS节点
ROS基础 - 使用 launch 文件(一) - 批量启动多个ROS节点
2022-06-11 02:33:00 【NiuniuAndAdu】
ROS基础 - 使用 launch 文件(一) - 批量启动多个ROS节点
本文主要介绍launch文件的基本使用,详细的launch文件格式说明及 传递 ROS参数param 的方法,详见: https://aduandniuniu.blog.csdn.net/article/details/125181523?spm=1001.2014.3001.5502
roslaunch命令可以用来启动定义在launch(启动)文件中的节点。
roslaunch不保证节点开始的顺序,因为无法从外部知道何时完全初始化节点,因此所有启动的代码都必须能够按任意顺序启动。。
命令格式:
roslaunch [package] [filename.launch]
1、新建ROS工程
$ mkdir -p ~/launchExample/src
$ cd ~/launchExample/src
$ catkin_init_workspace //初始化工作区
$ catkin_create_pkg launchTest1 roscpp //创建ROS工程包(pachage)
$ catkin_create_pkg launchTest2 roscpp //创建ROS工程包(pachage)
$ mkdir launch //创建.launch文件存放目录
$ cd ~/launchExample/
$ catkin_make
2、新建 test.launch 文件
新建 ~/launchExample/launch/test.launch文件,内容如下:
<launch>
<node pkg="launchTest1" type="launchTest1_node" name="launchTest1_node" output="screen" args="" />
<node pkg="launchTest2" type="launchTest1_node" name="launchTest2_node" output="screen" args="" />
</launch>
注意:其中的 type字段,要与对应功能包中, CMakelist.txt 中add_executable 指定的ROS程序一致。
3编写测试代码
3.1新建 launchTest1 测试程序
新建 ~/launchExample/launchTest1/main.cpp 文件,内容如下:
void main()
{
printf(“Hello LaunchTest1”);
}
3.2新建 launchTest2 测试程序
新建 ~/launchExample/launchTest2/main.cpp 文件,内容如下:
void main()
{
printf(“Hello LaunchTest2”);
}
$ cd ~/launchExample/
$ catkin_make
$ source devel/setup.bash //设置运行环境
4、roslaunch 命令启动ROS节点
4.1 启动方法1
roslaunch test.launch //不指定ROS包路径
4.2 启动方法2
catkin_create_pkg launchStart roscpp //创建ROS工程包(pachage)
cp ~/launchExample/launch/test.launch ~/launchExample/launchStart/
roslaunch launchStart test.launch //指定ROS包路径
5 launch文件格式 - 示例1
<launch>
<node pkg="turtlesim" name="sim1" type="turtlesim_node"/>
<node pkg="turtlesim" name="sim2" type="turtlesim_node"/>
</launch>
<launch>
<group ns="turtlesim1">
<node pkg="turtlesim" name="sim" type="turtlesim_node"/>
</group>
<group ns="turtlesim2">
<node pkg="turtlesim" name="sim" type="turtlesim_node"/>
</group>
<node pkg="turtlesim" name="mimic" type="mimic">
<remap from="input" to="turtlesim1/turtle1"/>
<remap from="output" to="turtlesim2/turtle1"/>
</node>
</launch>
边栏推荐
猜你喜欢

Explication du cours de graphacademy: neo4j Graph Data Science Foundation
![【长时间序列预测】Aotoformer 代码详解之[3]模型整体架构分析](/img/77/30215c363ae8a1324db1cbcaa5324b.png)
【长时间序列预测】Aotoformer 代码详解之[3]模型整体架构分析

The two request sessionids of the same user are inconsistent ----- record the problem

Why did those who left Beijing, Shanghai and Guangzhou with a smile cry in the end?
![[big guy show] aiops in the eyes of Borui data, choosing the right track and the right people](/img/a6/61d125326fc81532a56858c384460f.jpg)
[big guy show] aiops in the eyes of Borui data, choosing the right track and the right people

Blue Bridge Cup_ Xiao Lan eats candy_ Pigeon nest principle / drawer principle

Application of the remote acquisition IOT gateway of the Bashir trough flowmeter in open channel flow monitoring
![[resolved] how to fix another update in progress WordPress upgrade error](/img/b1/7b9945c1a623c20288f0d232cbb0c4.jpg)
[resolved] how to fix another update in progress WordPress upgrade error

Will your company choose to develop data center?

巴歇尔槽流量计远程采集物联网关在明渠流量监测的应用
随机推荐
Go 语言的优势和学习路线图
蓝桥杯_小蓝吃糖果_鸽巢原理 / 抽屉原理
軟件測試英語常見詞匯
Xampp is used under M1 chip, and the installation extension error
Can Xiaoxiang life become the "Yonghui" in the discount industry after the completion of the round a financing of tens of millions of yuan?
[implementation of bubble sorting]
Fundamentals of deep learning [4] build easyocr and carry out simple character recognition from 0
Databinding escaping with presentation symbols
Istio安装与使用
两部门联合印发《校外培训机构消防安全管理九项规定》
Openjudge noi 1.13 17: text layout
What is ttfb
Google Gmail mailbox marks all unread messages as read at once
Flat data to tree and tree data flattening
Arduino Uno接JQ8900-16p语音播报模块
重磅直播!ORB-SLAM3系列之特征匹配(MLPnP、词袋模型等)。
Application of the remote acquisition IOT gateway of the Bashir trough flowmeter in open channel flow monitoring
CPT 102_LEC 20
微信模版消息errcode“:40165,“errmsg“:“invalid weapp pagepath
CPT 102_ LEC 20