Ros学习——roslaunch

roslaunch:启动定义在launch文件中的多个节点

1.launch文件解析

<launch>  #以launch标签开头以表明这是一个launch文件
      #两个节点分组并以'命名空间(namespace)'标签来区分,其中一个名为turtulesim1,另一个名为turtlesim2
  <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> </launch>

 2.启动

$ roslaunch beginner_tutorials turtlemimic.launch
$ rostopic pub /turtlesim1/turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'

  

 

 

 3.解析:上述程序给第一个小海龟发送了逆时针旋转运动指令,通过mimic传给了第二个小海龟

posted @ 2018-11-20 16:03  寒江小筑  阅读(339)  评论(0编辑  收藏  举报