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

How to set the dynamic reconfigure min, max values programmatically?

asked 2015-06-18 17:38:37 -0500

lucasw gravatar image

updated 2020-11-21 11:30:07 -0500

Is there a way to change the dynamic reconfigure min max (and even default) values at run time?

The use case I have is that there are a set of cameras that a node can connect to with different min and max exposures, and I would like node to query the camera and get those values then have the server reflect them.

Just looking at it has dynamic reconfigure support but for things like width there is a huge zero to 2 billion range- the slider in the rqt node isn't going to be very useful for that control.

I've taken a cursory look at a header file generated from a cfg, I see __getMin__() and __getMax__() methods but no setters, and I see a FooBarConfigStatics() constructor that has the hard coded values generated from the python file.

edit retag flag offensive close merge delete


Did you find a solution to this?

Zubin Priyansh gravatar image Zubin Priyansh  ( 2016-02-18 15:56:25 -0500 )edit

Not using the dynamic reconfigure. In one project ( ) I set up a bunch of subscribers with rosparams to define their type, min and max, and the publisher goes through the rosparams and creates rqt controls for each- it isn't finished yet though.

lucasw gravatar image lucasw  ( 2016-02-19 10:34:16 -0500 )edit

Ok thanks! I'll have a look at it.

Zubin Priyansh gravatar image Zubin Priyansh  ( 2016-02-19 15:42:06 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-04-23 06:42:21 -0500

lucasw gravatar image

updated 2016-10-20 11:12:02 -0500

My current hacky and likely very brittle solution is to create the python dynamic reconfigure module at runtime that is normally created at compile time.

This shows the creation of the module and a dynamic reconfigure server from it: It requires rosparams to exist in a certain format on the same namespace.

And an application specific example that creates the params is at

Because the node in control of the hardware is in C++, it can't use the python reconfigure server, so there is an intermediary layer of regular ros topics to communicate from the dr server to C++ node.

The params look like:


(_default for each control would be a good addition.)

The standard generated python object looks like devel/lib/python2.7/dist-packages/screen_grab/cfg/

from dynamic_reconfigure.encoding import extract_params
inf = float('inf')

config_description = {'upper': 'DEFAULT', 'lower': 'groups', 'srcline': 235, 'name': 'Default', 'parent': 0, 'srcfile': '/opt/ros/jade/lib/python2.7/dist-packages/dynamic_reconfigure/', 'cstate': 'true', 'parentname': 'Default', 'class': 'DEFAULT', 'field': 'default', 'state': True, 'parentclass': '', 'groups': [], 'parameters': [{'srcline': 280, 'description': 'x offset', 'max': 2048, 'cconsttype': 'const int', 'ctype': 'int', 'srcfile': '/opt/ros/jade/lib/python2.7/dist-packages/dynamic_reconfigure/', 'name': 'x_offset', 'edit_method': '', 'default': 0, 'level': 1, 'min': 0, 'type': 'int'}, 

min = {}
max = {}
defaults = {}
level = {}
type = {}
all_level = 0

for param in extract_params(config_description):
    min[param['name']] = param['min']
    max[param['name']] = param['max']
    defaults[param['name']] = param['default']
    level[param['name']] = param['level']
    type[param['name']] = param['type']
    all_level = all_level | param['level']

So if that format changes it would break my system. But likely I could generate an actual cfg and generate the python Config file at run time, and this would make the code more future proof. (just need to see what the generation commands are)

Can I change the min and max values or add new controls during execution? Maybe but rqt_reconfigure would probably have to be refreshed to see them.

I don't think this is possible for C++, for that the only solution may be dynamic reconfigure itself ought to change so there is an api to create any control prior to setting up the server.


I haven't looked at this in detail at this 'dynamic dynamic reconfigure' solution, it may be doing something similar to my code or perhaps has a more robust approach:

edit flag offensive delete link more

Question Tools



Asked: 2015-06-18 17:38:37 -0500

Seen: 2,537 times

Last updated: Oct 20 '16