ROS學習之launch檔案編寫
阿新 • • 發佈:2019-01-07
1.一個簡單的launch檔案
//在catkin_ws/src/下建立一個包,單獨存放launch 檔案 cd catkin_ws/src catkin_create_pkg my_launch //回到catkin_ws目錄下 catkin_make
在包 my_launch 裡建立一個turtle.launch檔案,寫入下面的內容:
<launch> <node pkg="turtlesim" name="my_turtle" type="turtlesim_node" /> <node pkg="turtlesim" name="keyboard" type="turtle_teleop_key" /> </launch>
第二行的意思是要開啟pkg="turtlesim"包下的type="turtlesim_node"節點,併為節點取新名字為my_turtle。
//呼叫launch檔案
roslaunch my_package turtle.launch
//列印正在執行的節點
rosnode list
2.稍微複雜的launch檔案
在my_launch包裡建立一個turtlesim_advertise.launch檔案,寫入以下內容:
<launch> <include file="$(find my_launch)/turtle.launch"/> <node pkg="my_pkg" name="publisher" type ="publisher_Node" required="true" output="screen" /> <node pkg="my_pkg" name="subscriber" type ="subscriber_Node" output="screen" respawn="true"> </node> </launch>
執行turtle_advertise.launch
roslaunch my_launch turtle_advertise.launch
更多關於launch檔案的參考:http://wiki.ros.org/roslaunch/XML/