ROS 檔案設定
launch files
- ROS 檔案設定
-
- launch
- launch檔案
launch
launch檔案
<launch>
<!-- turtlebot_teleop_key already has its own built in velocity smoother -->
<node pkg="turtlebot_teleop" type="turtlebot_teleop_key.py" name="turtlebot_teleop_keyboard" output="screen">
<param name="scale_linear" value="0.5" type="double"/>
<param name="scale_angular" value="1.5" type="double"/>
<remap from="turtlebot_teleop_keyboard/cmd_vel" to="/cmd_vel"/> <!-- cmd_vel_mux/input/teleop"/-->
</node>
</launch>
All launch files are contained within a tag. Inside that tag, you can see a tag, where we specify the following parameters:
- pkg=“package_name” # Name of the package that contains the code of the ROS program to execute
- type=“python_file_name.py” # Name of the program file that we want to execute
- name=“node_name” # Name of the ROS node that will launch our Python file
- output=“type_of_output” # Through which channel you will print the output of the Python file
-
output
将标準輸出顯示在螢幕上而不是記錄在日志中,
output="screen"
-
respawn
請求複位,當該屬性的值為
時,roslaunch會在該節點崩潰時重新啟動該節點respawn="true"
-
required
必要節點,當該值為
時,roslaunch會在該節點終止時終止其他活躍節點。required="true"
-
啟動字首
在啟動指令加上字首。例如當其設定為
時,效果類似于launch-prefix="xterm -e"
。也就是為該節點保留獨立的終端。xterm -e rosrun X X
-
ns
在命名空間中啟動節點。
-
重映射
使用方法
remap from="original-name(turtle/pose)"to"new-name(tim)"
- 包含其他檔案
在啟動檔案中包含其他啟動檔案的内容(包括所有的節點和參數),可使用如下指令使路徑更為簡單include file="path to launch file"
include file="($find package-name)/launch-file-name"
-
啟動參數(launch arguments)
為了使啟動檔案便于配置,roslaunch還支援啟動參數,有時也簡稱為參數甚至args,其功能有點像可執行程式中的局部變量。
聲明參數:
arg name="arg-name"
然而這樣的聲明并不是必須的(除非你想要給它指派或設定為預設值,見後續内容),但是這是一個好的做法,因為這樣能使讀者比較清楚啟動檔案需要哪些參數
參數指派:
roslaunch package-name launch-file-name arg-name:=arg-value
<arg name=”arg-name” default=”arg-value”/>
擷取參數:一旦參數值被聲明并且被指派,你就可以利用下面的arg 替換(arg substitution)文法來使用該參數值了:$(arg arg-name)每個該替換出現的地方,roslaunch 都将它替換成參數值。在示例中,我們在 group 元素中的 if 屬性使用了一次 use_sim3 參數。<arg name=”arg-name” value=”arg-value”/>