如何在启动文件中定义参数?

问题描述

我有以下启动文件,我在其中定义了一个参数:

<launch>
<arg name="coordinates_file" value="$(find pkg_name)/name_of_the_txt_file.txt"/>
  <node pkg="pkg_name" type="ros_node_name" name="launch_file_name">
    <rosparam file="$(arg coordinates_file)"/>
  </node>
</launch>

另外,我正在读取 ros_node 中的参数如下:

  ros::NodeHandle nh("~");
  std::string param="waypoints_cordinates.txt";
  std::string wp_file;
  wp_file = nh.getParam("wp_file",param);
  std::cout << "param1" << param  << std::endl;
  std::cout << "param" << wp_file  << std::endl;

在对上述启动文件执行 roslaunch 时,我遇到以下错误

RLException: error loading <rosparam> tag: 
        'param' attribute must be set for non-dictionary values
XML is <rosparam file="$(arg wp_file)"/>
The traceback for the exception was written to the log file

你能帮我解决这个问题吗?我是否错过了创建和读取参数的任何部分?!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)