4 Dynamic dynamic reconfigure server.
6 Just register your variables for the dynamic reconfigure
7 and call start with a callback.
12 from dynamic_reconfigure.server
import Server
13 from dynamic_reconfigure.parameter_generator_catkin
import ParameterGenerator
14 from dynamic_reconfigure.encoding
import extract_params
15 from rospkg
import RosPack
20 """Dynamic reconfigure server that can be instanced directly."""
24 self.
group = self.Group(self,
"Default",
"",
True, 0, 0)
27 self.
name = rospy.get_name() +
"_dyn_rec"
35 class TypeClass(object):
36 def __init__(self, config_description):
45 for param
in extract_params(config_description):
46 self.
min[param[
'name']] = param[
'min']
47 self.
max[param[
'name']] = param[
'max']
48 self.
defaults[param[
'name']] = param[
'default']
49 self.
level[param[
'name']] = param[
'level']
50 self.
type[param[
'name']] = param[
'type']
52 return TypeClass(self.
group.to_dict())
54 def add_variable(self, name, description, default=None, min=None, max=None, edit_method=""):
55 """Register variable, like gen.add() but deducting the type"""
56 if type(default) == int:
58 self.add(name,
"int", 0, description, default, min, max)
60 self.add(name,
"int", 0, description, default, min, max, edit_method)
61 elif type(default) == float:
62 self.add(name,
"double", 0, description, default, min, max)
63 elif type(default) == str:
64 self.add(name,
"str", 0, description, default)
65 elif type(default) == bool:
66 self.add(name,
"bool", 0, description, default)
72 """Return the names of the dynamic reconfigure variables"""
74 for param
in self.
group.parameters:
75 names.append(param[
'name'])