19.launch启动文件的使用方法

19.launch启动文件的使用方法

1、Launch文件
在这里插入图片描述
2、在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
3、launch示例
3.1 创建learning_launch
chen@ubuntu:~/catkin_ws/src$ catkin_create_pkg learning_launch
3.2 在learning_launch里面创建文件夹launch
并创建文件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>

3.3 编译

chen@ubuntu:~/catkin_ws$ catkin_make

3.4 启动launch文件

chen@ubuntu:~$ roslaunch learning_launch simple.launch

4、示例二,参数设置
在这里插入图片描述

<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"/>
		//param.yaml是一个参数文件,$(find learning_launch)是搜索功能包指令,会输出一个完整路径
	</node>

    <node pkg="turtlesim" type="turtle_teleop_key" name="turtle_teleop_key" output="screen"/>
//启动键盘控制节点
</launch>

在这里插入图片描述
复制config文件夹;
运行launch

chen@ubuntu:~$ roslaunch learning_launch turtlesim_parameter_config.launch

进入参数节点

chen@ubuntu:~$ rosparam list
/background_b
/background_g
/background_r
/rosdistro
/roslaunch/uris/host_ubuntu__42281
/rosversion
/run_id
/turtle_number
/turtlesim_node/A
/turtlesim_node/B
/turtlesim_node/group/C
/turtlesim_node/group/D
/turtlesim_node/turtle_name1 //同为参数,但名字与/turtle_number有区别,是因为/turtle_number参数写在了节点前
/turtlesim_node/turtle_name2
chen@ubuntu:~$ rosparam get /turtle_number
2

5、示例3,海龟跟随launch文件
不需要启动roscore

chen@ubuntu:~$ roslaunch learning_launch start_tf_demo_c++.launch 

6、启动incude文件

<launch>

	<include file="$(find learning_launch)/launch/simple.launch" />
	//包含simple.launch文件

    <node pkg="turtlesim" type="turtlesim_node" name="turtlesim_node">
		<remap from="/turtle1/cmd_vel" to="/cmd_vel"/>
		//重映射
	</node>

</launch>

启动

chen@ubuntu:~$ roslaunch learning_launch turtlesim_remap.launch
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值