ROS中可以把很多的命令以描述的形式写成launch文件,然后用
roslaunch命令执行launch文件。
它的使用方法如下:
比如:我们切换到 beginner_tutorials文件下:
注:如果提示找不到文件或文件夹,就参照前面把环境变量设置一下。执行:
和
在beginner_tutorials文件夹下, 创建launch文件夹,切换到该文件夹下:
和
输入:
用ubuntu默认的编辑器gedit创建一个launch文件。
然后在打开的的launch文件中复制入下面的内容:
保存退出就可以了。
就可以看到新打开两个乌龟节点。
使乌龟运动起来。就可以看到两只乌龟都在运动。
输入命令:
就可以看到启动了两个节点 /turtlesim1/sim和 /turtlesim2/sim。如图:
转载说明:http://www.arduino.cn/thread-12413-1-1.htmlhttp://www.arduino.cn/thread-12413-1-1.html
比如:我们切换到 beginner_tutorials文件下:
注:如果提示找不到文件或文件夹,就参照前面把环境变量设置一下。执行:
和
在beginner_tutorials文件夹下, 创建launch文件夹,切换到该文件夹下:
和
输入:
用ubuntu默认的编辑器gedit创建一个launch文件。
然后在打开的的launch文件中复制入下面的内容:
[C]
纯文本查看
复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
|
<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>
|
保存退出就可以了。
现在使用如下命令载入刚才创建的launch文件:
就可以看到新打开两个乌龟节点。
新打开一个终端,输入命令
使乌龟运动起来。就可以看到两只乌龟都在运动。
输入命令:
就可以看到启动了两个节点 /turtlesim1/sim和 /turtlesim2/sim。如图:
下面来解析一下launch文件的标签的意思:
<lanuch>
<lanuch>标签用来识别这是一个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>
上面的内容表示我们启动了两只乌龟。分别名为turtlesim1和turtlesim2.
<node pkg="turtlesim" name="mimic" type="mimic">
<remap from="input" to="turtlesim1/turtle1"/>
<remap from="output" to="turtlesim2/turtle1"/>
</node>
上面的内容使turtlesim2模仿turtlesim1。所以虽然我们只向turtlesim1发布了话题,turtlesim2也做出了反应。
转载说明:http://www.arduino.cn/thread-12413-1-1.htmlhttp://www.arduino.cn/thread-12413-1-1.html