In ROS, roslaunch is used to run a bunch of node together by using rosrun to simplify the launch process. roslaunch will start roscore if it not start.
roslaunch pkg xxx.launch.launch format
Create launch directory in pkg directory and create .launch file inside it.
<launch>
<node
pkg="pkg_name"
type="node_type" <!-- same with exec file name -->
name="node_name"
args="xxx" <!-- args used by exec file -->
respawn="true" <!-- restart node if node exit -->
required="true" <!-- kill the whole launch if current node exit -->
output="log | screen" <!-- output to log file or screen -->
ns="namespace"
>
<!-- env, remap, rosparam, param -->
</node>
<!-- include another launch file into current launch -->
<include file="path/to/xxx.launch"></include>
<!-- rename topic -->
<remap from="original topic name" to="target topic name"/>
<!-- set params in parameter server -->
<param name="param name"
value="param value"
type="str | int | double | bool | yaml"/>
<!-- load, dump or delete params from/to file -->
<rosparam command="load | dump | delete"
file="path/to/xxx.yaml"
param="param name"
ns="namespace"/>
<!-- grouping nodes into different namespace -->
<group ns="namespace" clear_params="true | false">
<!-- all other except launch -->
</group>
</launch>How to avoid params duplication?
rosrun
# _param_name:=value
rosrun turtlesim turtlesim_node _A:=100roslaunch
<launch>
<param name="p1" value="100" />
<node pkg="turtlesim" type="turtlesim_node" name="t1">
<param name="p1" value="100" />
</node>
</launch>- code
# init node with name hello and namespace xxx
# global param
# /py_A
rospy.set_param("/py_A",100)
# relative param
# /xxx/py_A
rospy.set_param("py_A",100)
# private param
# /xxx/hello/py_A
rospy.set_param("~py_A",100) #私有,参考命名空间与节点名称