# Dynamic reconfigure default values not working

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

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)



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")


edit retag close merge delete

Sort by » oldest newest most voted

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.

more

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.

more

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!!
( 2012-01-31 23:45:02 -0500 )edit

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.

more

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!
( 2012-01-31 23:43:16 -0500 )edit

## Stats

Seen: 3,109 times

Last updated: Jan 31 '12