setting parameters in ros launch file programatically
Hi All, I want to set the parameters value on the fly in launch file through command line option . Below is the way to achieve the same but in roscpp is there any API which can be used to search the param name from launch file and set the value in launch file.
roslaunch pkg file.launch argname:=argvalue arg2name:=arg2value
Asked by can-43811 on 2017-07-12 11:18:22 UTC
Answers
No, however, this is also not what those parameters are for.
If you want to set parameters "on the fly", you should use dynamic_reconfigure
Link.
If you want to actually edit launch files from a program, you would have to write this yourself (e.g. by plugging into the roslaunch
API).
Or, if you just want to change parameters that are on the parameter server (i.e. after the launch file has been launched), you could use the getParam
/setParam
functions. Then again, this will not let nodes reload those parameters easily. this is what dynamic_reconfigure
is for.
EDIT1
This cannot be done using ROS standard tools. If this is coming from the outside world (i.e. non-ROS), I'd suggest you create a program that reads the launch file (you need to pass in the file path, or you could tap into the rospack API to get the path of the file), edit what you need, and rewrite it.
Asked by mgruhler on 2017-07-13 01:59:23 UTC
Comments
Thanks for your input. Actually i want to edit launch file from a program . Does it mean through c++ system API i need to execute the below command. roslaunch pkg file.launch arg_name:=arg_value .
However till now i am able to set only one parameter , not able to set the multiple parameters .
Asked by can-43811 on 2017-07-13 07:17:46 UTC
would u like to also suggest me to use xml parser (boost libraries) to get this job done .
Asked by can-43811 on 2017-07-13 07:19:18 UTC
If you want to edit a launch file by a program, best write something like an editor to open it and edit it their...
I must say, I am at a loss on your actual goal....
Asked by mgruhler on 2017-07-13 07:37:51 UTC
As per my need i will be receiving parameters from configuration file and same i need to set in launch file.
Asked by can-43811 on 2017-07-13 10:13:24 UTC
Hi... Let me clear.. I want to "launch the node" with specific parameters which will be received from external world. i.e. Before running the launch the file I want to update specific parameters of node. I want to do all these using program, not through command line.
Asked by can-43811 on 2017-07-13 23:53:08 UTC
see EDIT1 above
Asked by mgruhler on 2017-07-14 06:58:44 UTC
You could load a yaml file from the Lauch File. Thereby your 'outside world' Programm could Specify the params by creating a yaml file and then Lauch the roslauch and Point it to the created yaml file that roslauch loads via rosparam load.....
Edit:
ros uses yaml-cp as stated here:
http://answers.ros.org/question/12321/how-to-write-and-parse-yaml-file-for-ros/
Link to yaml-cpp:
https://github.com/jbeder/yaml-cpp
Asked by Wolf on 2017-07-14 08:50:21 UTC
Comments
Thanks . if possible could you share any ros related yaml library to parse the data.
Asked by can-43811 on 2017-07-14 09:53:43 UTC
Comments