ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I found this way to pass the current shell path to the xml launch file:

<arg name="file_path"  default="$(env PWD)"/>

and then the file name to read

<arg name="file_name"  default="file_name"/>

Finally, I pass the file name as a parameter to my C++ package:

<node pkg="pkg_name"  type="node_type"    name="node_name"  output="screen" >
   <param name="file_name"  value="$(arg file_name)"  type="string" />
</node>

Then, I use these arguments as entries for a C++ file in which I concatenate the two arguments.

Note : I get the value of these arguments in my C++ program through

std::string path, file;
ros::param::get("/node_name/file_path", path);
ros::param::get("/node_name/file_name", file);

I am using Ubuntu 18.04 with ROS Melodic. Hope it can help.