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

Provide parameters to OpenCV C++ program in ROS from external file

asked 2013-03-16 08:23:36 -0500

KarthikMurugan gravatar image

updated 2013-03-16 08:26:52 -0500

I want to write a program using OpenCV C++ interface in ROS. I want to provide parameters used by the program from external file(not sure which format will be apt).

Say, I use the threshold function in the program, instead of changing the threshold value each time in the program,make and then run, I want the program to fetch the threshold value from a file so that if I wish to change any value, I could do it in the external file.

I want this because I think it will be helpful to a third-person who can just change the various parameters in the file and observe the result rather than opening the program, change values,make and run (Sometimes the third person may not be a programmer and just wishes to see the results, in that case he would not know the technicalities of where to change parameters in the program)

I am new to ROS. I am using Fuerte. Is there any way to do this in ROS ??

Thank you

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-03-16 08:58:08 -0500

Chad Rockey gravatar image

More specifically, check out roslaunch and the ability to import parameters via yaml files.

http://www.ros.org/wiki/roslaunch

http://www.ros.org/wiki/roslaunch/XML/rosparam

And a sample of how to include the parameters: http://www.ros.org/wiki/ROS/Tutorials/Roslaunch%20tips%20for%20larger%20projects#roslaunch.2BAC8-Tutorials.2BAC8-Roslaunch_tips_for_larger_projects.Parameters.2C_namespaces.2C_and_yaml_files

So after you change the file, you only need to run in the command line: "roslaunch package something.launch"

edit flag offensive delete link more

Comments

1

This is definitely the best approach. You can also specify command-line args to launch files, allowing you to specify the YAML (config) file to use each time you launch the node. Also, you can load a set of default values from a YAML file and use cmd-line args to override indiv. params at runtime.

Jeremy Zoss gravatar image Jeremy Zoss  ( 2013-03-17 19:29:17 -0500 )edit
1

answered 2013-03-16 08:55:02 -0500

dornhege gravatar image

ROS provides functionality for exactly that purpose. The Paramter Server. Have a look at that.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-16 08:23:36 -0500

Seen: 723 times

Last updated: Mar 16 '13