How to use txt file as a parameter to roslaunch file?
Hello All,
Background:
My idea is to receive not constant number of topics, to which I want to subscribe in my C code. I decided to do it in the next way: I will prepare a text file with the number and the name of the topics ---> convert it using launch file syntax to a string ---> parse the string in my C code ---> decide to which topics to subscribe.
In such a way I will only have to change the text file, while the launch file and the C code will not be changed.
Question:
I have written the next line of code in my launch file:
<param name="topics_list" textfile="$(find package_name)/file_name.txt"/>
And I have placed my text file in the appropriate folder. In my C file I do the next:
if ( nh.getParam("topics_list", topicsList) )
{
ROS_INFO ("The contents of the file \"file_name.txt\" as a string are: %s\n",
topicsList);
}
else
{
ROS_INFO ("The topics list was not loaded succesfully. Aborting...\n");
ros::shutdown();
}
It doesn´t work.
- Is my way correct?
- Why the above doesn´t work properly?
Thank you all in advance, Felix.