大家好,欢迎来到IT知识分享网。
1、lauch文件作用:启动程序,比rosrun更方便,会自动启动roscore。
2.lauch语法
(1)launch
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>
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/138418.html