ROS 文件設置
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
請求復位,當該屬性的值爲respawn="true"
時,roslaunch會在該節點崩潰時重新啓動該節點 - required
必要節點,當該值爲required="true"
時,roslaunch會在該節點終止時終止其他活躍節點。 - 啓動前綴
在啓動命令加上前綴。例如當其設置爲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 name=”arg-name” value=”arg-value”/>
獲取參數:一旦參數值被聲明並且被賦值,你就可以利用下面的arg 替換(arg substitution)語法來使用該參數值了:$(arg arg-name)每個該替換出現的地方,roslaunch 都將它替換成參數值。在示例中,我們在 group 元素中的 if 屬性使用了一次 use_sim3 參數。