ROS launch開機檔案__xml

來源:互聯網
上載者:User

ROS採用rosrun命令可以啟動一個節點,如果需要同時啟動節點管理器(master)和多個節點,就需要採用launch檔案來配置。launch檔案是一種特殊的XML格式檔案,通常以.launch作為檔案尾碼。每個launch檔案都必須要包含一個根項目。

roslaunch的使用方法為:
$ roslaunch pkg-name launch-file-name

下面以一個典型的launch檔案舉例說明:

<launch>  <!-- these are the arguments you can pass this launch file, for example paused:=true -->  <arg name="debug" default="true"/>  <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->   <include file="$(find gazebo_ros)/launch/empty_world.launch">     <arg name="debug" value="$(arg debug)" />  </include>  <!-- Load the URDF into the ROS Parameter Server -->  <arg name="model" />  <param name="robot_description"      command="$(find xacro)/xacro.py $(arg model)" />  <!-- Run a python script to the send a service call to gazebo_ros to spawn a URDF robot -->   <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"    args="-urdf -model robot1 -param robot_description -z 0.05"/> </launch>

launch
每個launch檔案都必須且只能包含一個根項目。根項目由一對launch標籤定義,其他所有元素標籤都應該包含在這兩個標籤之內。

<launch>...</launch>

arg
roslaunch支援啟動參數arg,可以通過設定arg來改變程式的運行。name為啟動參數的名稱,default為該參數的預設值,value為該參數的參數值。
default與 value兩者的唯一區別在於命令列參數roslaunch pkg-name launch-file-name arg-name:=”set-value”可以覆蓋預設值default,但是不能覆蓋參數值 value。在launch檔案中出現$(arg arg-name)的地方,運行時roslaunch 會將它替換成參數值。並且可以在include元素標籤內使用arg來設定所包含的launch檔案中的參數值。

param
在ROS中prarmeter和argument 是不同的,雖然翻譯一樣。parameter是運行中的ROS系統使用的數值,儲存在參數伺服器(parameter server)中,每個活躍的節點都可以通過 ros::param::get 函數來擷取parameter的值,使用者也可以通過rosparam來獲得parameter的值而argument只在開機檔案內才有意義他們的值是不能被節點直接擷取的。

include
在launch檔案中複用其他launch檔案可以減少代碼編寫的工作量,提高檔案的簡潔性。使用包含元素include在launch檔案中可包含其他launch檔案中所有的節點和參數。

 <include file="$(find pkg-name)/launch/launch-file-name">      <arg name="arg_name" value="set-value"/>  </include>

node
節點的形式為:

<node name="node-name" pkg="pkg-name" type="executable-name" />

node的三個屬性分別為節點名字、程式包名字和 可執行檔的名字。 name屬性給節點指派了名稱,它將覆蓋任何通過調用 ros::init來賦予節點的名稱。另外node標籤內也可以用過arg設定節點參數值。如果node標籤有children標籤,就需要顯式標籤來定義。即末尾為/node>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.