ros之launch檔案
阿新 • • 發佈:2021-06-26
目錄
常規
<launch> <arg name="model" default="model_name" doc="this is a model name"/> <arg name="param_path" default="$(find package_name)/data/" doc="this is a param path" /> <group ns="group_name"> <node pkg="package_name1" name="node_name1" type="node_type1" output="screen" > <param name="model" value="$(arg model)"/> <param name="param_path" value="$(arg param_path)/xx.xml" /> <remap from="old_topic" to="new_topic"/> </node> </group> <node pkg="package_name2" name="node_name2" type="node_type2" output="screen" > <param name="string" type="str" value="ABC" /> <param name="int" type="int" value="6" /> <rosparam param="min_in">[1, 1, 1]</rosparam> <rosparam param="paras"> "a": 1 "b": 2 </rosparam> </node> <node pkg="rviz" name="rviz" type="rviz" args="-d $(find package_name)/rviz/package_name.rviz"> </node> </launch>
type和name
<node pkg="package_name2" name="node_name2" type="node_type2" output="screen" >
注: type為可執行檔案的名字, 那麼就是node的名字.
group組名
<group ns="group_name">
</group>
注: 如果裡面的設定的輸出topic為/rslidar_points
, 這不帶組名. 如果為rslidar_points
, 則帶組名.
topic重對映
<remap from="old_topic" to="new_topic"/>
設定引數
<param name="string_name" type="str" value="ABC" />
<param name="int_name" type="int" value="6" />
<param name="param_path" value="$(arg param_path)/xx.xml" />
支援 string、 int 、double和file(xml, csv等)
ros::NodeHandle priv_nh("~"); std::string string_name; priv_nh.param<std::string>("string_name", string_name, "string_defalut"); priv_nh.param<int>("int_name", int, "0");
使用rosparam
<rosparam param="range">[1, 1, 1]</rosparam>
<rosparam param="paras">
"a": 1
"b": 2
</rosparam>
使用rosparam向node傳輸引數
std::vector<double> v_range(3, 0);
priv_nh.getParam("range", v_range);
std::map<std::string, double> m_paras;
priv_nh.getParam("paras", m_paras);
呼叫launch
<include file="$(find rs_fusion)/../../launch/lidar_driver_four.launch" />
注: 可以使用..
表示上一層.
參考
How to create a launch file? - ROS Answers: Open Source Q&A Forum
roslaunch/XML - ROS Wiki