码迷,mamicode.com
首页 > 其他好文 > 详细

ros之launch文件

时间:2018-11-13 02:56:02      阅读:337      评论:0      收藏:0      [点我收藏+]

标签:设置   path   nod   create   pre   value   open   string   传输   

ros之launch文件

<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>
  • 对node设置组名
<group ns="group_name">
</group>
  • 对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);

参考

How to create a launch file? - ROS Answers: Open Source Q&A Forum
roslaunch/XML - ROS Wiki

ros之launch文件

标签:设置   path   nod   create   pre   value   open   string   传输   

原文地址:https://www.cnblogs.com/ChrisCoder/p/9949643.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!