Skip to content

Commit 2b46ee4

Browse files
authored
support float('inf') for cfg file (ros#168)
* support float('inf') for cfg file * add float in test.cft g
1 parent fa838a7 commit 2b46ee4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cfg/Test.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ gen.add("int_", int_t, 1, "Int parameter",0, -10, 10)
5151
gen.add("double_", double_t, 2, "double parameter", 0, -2, 10)
5252
gen.add("double_no_minmax", double_t, 2, "double parameter without boundaries", 1)
5353
gen.add("double_no_max", double_t, 2, "double parameter without max value", 2, 0)
54+
gen.add("double_inf", double_t, 2, "double parameter with inf", float('inf'), float('inf'), float('inf'))
55+
gen.add("double_negative_inf", double_t, 2, "double parameter with negative inf", -float('inf'), -float('inf'), -float('inf'))
5456
gen.add("str_", str_t, 4, "String parameter","foo")
5557
gen.add("mstr_", str_t, 4, "Multibyte String parameter","bar")
5658
gen.add("bool_", bool_t, 8, "Boolean parameter",False)

src/dynamic_reconfigure/parameter_generator_catkin.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,15 @@ def crepr(self, param, val):
404404
type = param["type"]
405405
if type == 'str':
406406
return '"' + val + '"'
407-
if type in ['int', 'double']:
407+
if type == 'int':
408408
return str(val)
409+
if type == 'double':
410+
if val == float('inf'):
411+
return 'std::numeric_limits<double>::infinity()'
412+
elif val == -float('inf'):
413+
return '-std::numeric_limits<double>::infinity()'
414+
else:
415+
return str(val)
409416
if type == 'bool':
410417
return {True: 1, False: 0}[val]
411418
raise TypeError(type)

0 commit comments

Comments
 (0)