dynamicreconfig-hg

changeset 222:18d7e22894b1 qt

Fix error where doubles without min/max were converted to strings
author Ze'ev Klapow <zklapow@willowgarage.com>
date Mon Jun 18 13:17:41 2012 -0700 (11 months ago)
parents ed1fe0030797
children 1ed20a2bc3b7
files src/dynamic_reconfigure/parameter_generator.py templates/ConfigType.py
line diff
     1.1 --- a/src/dynamic_reconfigure/parameter_generator.py	Fri Jun 15 16:13:00 2012 -0700
     1.2 +++ b/src/dynamic_reconfigure/parameter_generator.py	Mon Jun 18 13:17:41 2012 -0700
     1.3 @@ -62,14 +62,14 @@
     1.4  class ParameterGenerator:
     1.5      minval = {
     1.6              'int' : -0x80000000, #'INT_MIN',
     1.7 -            'double' : '-std::numeric_limits<double>::infinity()',
     1.8 +            'double' : -1e10000,#'-std::numeric_limits<double>::infinity()',
     1.9              'str' : '',
    1.10              'bool' : False,
    1.11              }
    1.12              
    1.13      maxval = {
    1.14              'int' : 0x7FFFFFFF, #'INT_MAX',
    1.15 -            'double' : 'std::numeric_limits<double>::infinity()',
    1.16 +            'double' : 1e10000, #'std::numeric_limits<double>::infinity()',
    1.17              'str' : '',
    1.18              'bool' : True,
    1.19              }
    1.20 @@ -128,6 +128,9 @@
    1.21              self.gen.check_type_fill_default(newparam, 'default', self.gen.defval[paramtype])
    1.22              self.gen.check_type_fill_default(newparam, 'max', self.gen.maxval[paramtype])
    1.23              self.gen.check_type_fill_default(newparam, 'min', self.gen.minval[paramtype])
    1.24 +
    1.25 +            print("Param: %s default: %s"%(newparam['name'], newparam['default']))
    1.26 +
    1.27              self.parameters.append(newparam)
    1.28  
    1.29          # Compile a list of all the parameters in this group
    1.30 @@ -390,8 +393,15 @@
    1.31          type = param["type"]
    1.32          if type == 'str':
    1.33              return '"'+val+'"'
    1.34 -        if type in [ 'int', 'double']:
    1.35 +        if type == 'int':
    1.36              return str(val)
    1.37 +        if type == 'double':
    1.38 +            if val == float('inf'):
    1.39 +                return 'std::numeric_limits<double>::infinity()'
    1.40 +            elif val == -float('inf'):
    1.41 +                return '-std::numeric_limits<double>::infinity()'
    1.42 +            else:
    1.43 +                return str(val)
    1.44          if  type == 'bool':
    1.45              return { True : 1, False : 0 }[val]
    1.46          raise TypeError(type)
     2.1 --- a/templates/ConfigType.py	Fri Jun 15 16:13:00 2012 -0700
     2.2 +++ b/templates/ConfigType.py	Mon Jun 18 13:17:41 2012 -0700
     2.3 @@ -42,6 +42,8 @@
     2.4  
     2.5  from dynamic_reconfigure.encoding import extract_params
     2.6  
     2.7 +inf = float('inf')
     2.8 +
     2.9  config_description = ${pycfgdata}
    2.10  
    2.11  min = {}