概述
1、lauch文件作用:启动程序,比rosrun更方便,会自动启动roscore。
2.lauch语法
(1)launch
(2)node
(3)param
(4)arg
(5)remap
(6)include
3.演示
(1)创建包
catkin_create_pkg learning_launch
可以在包的src下创建launch文件夹,将代码文件放在里面,方便管理。
(2)simple.launch
<launch>
<node pkg="learning_topic" type="person_subscriber" name="talker" output="screen" />
<node pkg="learning_topic" type="person_publisher" name="listener" output="screen" />
</launch>
- 编译工作空间
在工作空间的根目录下的终端输入
catkin_make
- 配置环境
source devel/setup.bash
- 运行
roslaunch learning_launch simple.launch
(3)turtlesim_parameter_config.launch
<launch>
<param name="/turtle_number" value="2"/>
<node pkg="turtlesim" type="turtlesim_node" name="turtlesim_node">
<param name="turtle_name1" value="Tom"/>
<param name="turtle_name2" value="Jerry"/>
<rosparam file="$(find learning_launch)/config/param.yaml" command="load"/>
</node>
<node pkg="turtlesim" type="turtle_teleop_key" name="turtle_teleop_key" output="screen"/>
</launch>
运行语句
roslaunch learning_launch turtlesim_parameter_config.launch
(4)start_tf_demo_c++.launch
(海龟跟随)
<launch>
<!-- Turtlesim Node-->
<node pkg="turtlesim" type="turtlesim_node" name="sim"/>
<node pkg="turtlesim" type="turtle_teleop_key" name="teleop" output="screen"/>
<node pkg="learning_tf" type="turtle_tf_broadcaster" args="/turtle1" name="turtle1_tf_broadcaster" />
<node pkg="learning_tf" type="turtle_tf_broadcaster" args="/turtle2" name="turtle2_tf_broadcaster" />
<node pkg="learning_tf" type="turtle_tf_listener" name="listener" />
</launch>
运行命令
roslaunch learning_launch start_tf_demo_c++.launch
(5)turtlesim_remap.launch
<launch>
<include file="$(find learning_launch)/launch/simple.launch" />
<node pkg="turtlesim" type="turtlesim_node" name="turtlesim_node">
<remap from="/turtle1/cmd_vel" to="/cmd_vel"/>
</node>
</launch>
最后
以上就是文静大树为你收集整理的lauch启动文件的使用方法的全部内容,希望文章能够帮你解决lauch启动文件的使用方法所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复