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

Dynamic reconfigure default values not working

asked 2012-01-31 07:20:59 -0600

Michi05 gravatar image

updated 2014-01-28 17:11:14 -0600

ngrennan gravatar image

Hi. I hope I'm not missing some silly thing but the default values in my dynamic reconfigure configuration are not working in my python node. Anybody else is using this and can tell me if this should work?

This is my cfg file:

#!/usr/bin/env python
PACKAGE = "image_adaptor"
import roslib;roslib.load_manifest(PACKAGE)

from dynamic_reconfigure.parameter_generator import *

gen = ParameterGenerator()

##  gen.add("name", type_t, level, "Description", DefaultValue, MinValue, MaxValue)
gen.add("prop_rgb_resolution", int_t, 0, "Specific resolution for RGB camera", 2, 1, 4)
gen.add("prop_rgb_frequency", int_t, 0, "Specific frequency for RGB camera", 30, 15, 60)
gen.add("prop_rgb_image_mode", int_t, 0, "Specific image mode for RGB camera", 2, 1, 9)


exit(gen.generate(PACKAGE, "image_adaptor", "Properties"))

The code is simplified and was done according to the tutorial (http://ros.org/wiki/dynamic_reconfigure/Tutorials/HowToWriteYourFirstCfgFile) but when I read the setted values they are always the maximum values instead of my defaults.

It looks like the usual silly mistake but this time I really can't find it.

This may be a clue or maybe it is a different problem but with a string vble the default value is the one in the first execution until I restart ros even if I recompile the cfg file and execute everything again:

gen.add("rect_rgb_image", str_t, 0, "Rgb rectified image", "Default Value")

Thanks in advance!

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2012-01-31 23:52:00 -0600

Michi05 gravatar image

In case somebody else is in the same situation: The exact problem was that I accidentally used the same names for other related variables so my launchfile was colliding with my configuration. For example I had put:

<param name="cur_tilt_angle" value="/cur_tilt_angle,std_msgs/Float64,publishedTopic" />

and in the configuration:

gen.add("cur_tilt_angle", double_t, 2, "Current real tilt of the camera", 0.0, -65.0, 65.0)

The problem was as silly as expected; I just forgot that both sets of variables go to the same parameter server so I didn't even check the names until now.

Thank you for your answers!!

edit flag offensive delete link more
4

answered 2012-01-31 18:48:30 -0600

raahlb gravatar image

updated 2012-01-31 20:22:22 -0600

I think dynamic_reconfigure writes the parameters' values as rosparam parameters, which are read the next time you start the node. Use "rosparam list" to look for the params, then you can delete them using "rosparam delete". Restarting the roscore should also clear all saved parameters.

Edit: To clarify, the default values are only used the first time you start the node, afterwards the last set values are used. Restarting roscore will reset the values to the defaults again.

edit flag offensive delete link more

Comments

Thanks for your answer! Even restarting roscore the setted values were wrong so it was not that. But it was a good clue: in the end I found colisions with the launchfile which had some text info in the param server about the same variables; that seemed to be causing the problem!!
Michi05 gravatar image Michi05  ( 2012-01-31 23:45:02 -0600 )edit
1

answered 2012-01-31 13:14:32 -0600

Thomas D gravatar image

Without seeing your source code I don't know if this is what's going on, but in the past I have seen this happen when I set variables using rospy.get_param() after I set up my dynamic reconfigure server. The reason for my problem is that I set my variables to values from the parameter server, thereby overwriting the variables I set earlier using the default dynamic reconfigure values. This has only been an issue when I have the same variable in my code set from both the parameter server and the dynamic reconfigure server.

edit flag offensive delete link more

Comments

Thanks for your answer! My problem was other, but not too diferent: I was overwriting parameters with the launchfile and different format (text); I guess that made parameters go crazy!! I will take your experience into account as well, thanks!
Michi05 gravatar image Michi05  ( 2012-01-31 23:43:16 -0600 )edit

Question Tools

Stats

Asked: 2012-01-31 07:20:59 -0600

Seen: 4,150 times

Last updated: Jan 31 '12