roslaunch使用示例

来源:互联网 发布:mac idea 两个窗口 编辑:程序博客网 时间:2024/05/22 01:27

        本文是看了学长ROSroslaunchxml相关要点 文章之后做了小改动,主要是对roslaunch文件的简单总结。需要完成的前序工作是已经创建了catkin工作空间;创建了catkin程序包(catkin_create_pkg beginner1 std_msgs rospy roscpp),本文中是beginner1;然后需要创建两个节点speaklisten(通过在beginner1/src目录中创建speak.cpplisten.cpp、修改CMakeLists.txt文件然后编译)。在本文中,speaklisten这两个node分别使用的是speakerlistener这两个topic

编译好两个node后,即可编辑launch文件:

roscd beginner1;mkdir launch;gedit combine.launch;

学长的文章中分别使用了两个launch文件运行两个node,因为luanch文件的作用正是可以运行多个node,所以本文中在combine.launch这个文件中直接调用两个node。内容如下:

<launch>        <node pkg="beginner1" name="tempspeak" type="speak" output="screen">      <remap from="speaker" to="listener"/>       </node>        <node pkg="beginner1" name="templisten" type="listen" output="screen">       <remap from="listener" to="listener"/>        </node> </launch>


需要注意的地方:tempspeak和 templisten是launch文件中创建的node(运行launch时会运行的node节点名字),他们的类型分别是已经编译好的speaklistenRemap speaker 到listener之后就可以让node通信。所以这个launch文件运行了两个node并让他们通信。

运行结果:


rqt_graph中:

 


0 0
原创粉丝点击