how to define a parameter in the launch file?

asked 2021-01-27 04:34:42 -0500

IKO gravatar image

Hello, I have the following launch file, in which I am defining a parameter:

<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>

Also, I am reading the parameter as following in the 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;

While doing roslaunch to the mentioned launch file, I am facing the following error:

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

Could you please help me in solving the problem? Did I miss any part of creating and reading a param?!

edit retag flag offensive close merge delete