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

setting parameters in ros launch file programatically

asked 2017-07-12 11:18:22 -0600

can-43811 gravatar image

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 arg_name:=arg_value arg2_name:=arg2_value

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-07-13 01:59:23 -0600

mgruhler gravatar image

updated 2017-07-14 06:58:31 -0600

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.

edit flag offensive delete link more

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 .

can-43811 gravatar image can-43811  ( 2017-07-13 07:17:46 -0600 )edit

would u like to also suggest me to use xml parser (boost libraries) to get this job done .

can-43811 gravatar image can-43811  ( 2017-07-13 07:19:18 -0600 )edit

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

mgruhler gravatar image mgruhler  ( 2017-07-13 07:37:51 -0600 )edit

As per my need i will be receiving parameters from configuration file and same i need to set in launch file.

can-43811 gravatar image can-43811  ( 2017-07-13 10:13:24 -0600 )edit

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.

can-43811 gravatar image can-43811  ( 2017-07-13 23:53:08 -0600 )edit

see EDIT1 above

mgruhler gravatar image mgruhler  ( 2017-07-14 06:58:44 -0600 )edit
0

answered 2017-07-14 08:50:21 -0600

Wolf gravatar image

updated 2017-07-16 01:21:58 -0600

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

Link to yaml-cpp:

https://github.com/jbeder/yaml-cpp

edit flag offensive delete link more

Comments

Thanks . if possible could you share any ros related yaml library to parse the data.

can-43811 gravatar image can-43811  ( 2017-07-14 09:53:43 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2017-07-12 11:18:22 -0600

Seen: 2,933 times

Last updated: Jul 16 '17