Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter conditionally enabled #180

Open
wants to merge 1 commit into
base: melodic-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions msg/ParamDescription.msg
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ string type
uint32 level
string description
string edit_method
string enable_if
3 changes: 2 additions & 1 deletion src/dynamic_reconfigure/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def encode_groups(parent, group):
msg.type = group['type']

for param in group['parameters']:
msg.parameters.append(ParamDescription(param['name'], param['type'], param['level'], param['description'], param['edit_method']))
msg.parameters.append(ParamDescription(param['name'], param['type'], param['level'], param['description'], param['edit_method'], param['enable_if']))

group_list.append(msg)
for next in group['groups']:
Expand Down Expand Up @@ -180,6 +180,7 @@ def params_from_msg(msg):
'level': param.level,
'description': param.description,
'edit_method': param.edit_method,
'enable_if': param.enable_if,
})
return params

Expand Down
11 changes: 6 additions & 5 deletions src/dynamic_reconfigure/parameter_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def add_group(self, name, type="", state=True):
self.groups.append(group)
return group

def add(self, name, paramtype, level, description, default=None, min=None, max=None, edit_method=""):
def add(self, name, paramtype, level, description, default=None, min=None, max=None, edit_method="", enable_if=""):
newparam = {
'name': name,
'type': paramtype,
Expand All @@ -137,6 +137,7 @@ def add(self, name, paramtype, level, description, default=None, min=None, max=N
'srcline': inspect.currentframe().f_back.f_lineno,
'srcfile': inspect.getsourcefile(inspect.currentframe().f_back.f_code),
'edit_method': edit_method,
'enable_if': enable_if,
}
if type == str_t and (max is not None or min is not None):
raise Exception("Max or min specified for %s, which is of string type" % name)
Expand Down Expand Up @@ -270,8 +271,8 @@ def enum(self, constants, description):
return repr({'enum': constants, 'enum_description': description})

# Wrap add and add_group for the default group
def add(self, name, paramtype, level, description, default=None, min=None, max=None, edit_method=""):
self.group.add(name, paramtype, level, description, default, min, max, edit_method)
def add(self, name, paramtype, level, description, default=None, min=None, max=None, edit_method="", enable_if=""):
self.group.add(name, paramtype, level, description, default, min, max, edit_method, enable_if)

def add_group(self, name, type="", state=True):
return self.group.add_group(name, type=type, state=state)
Expand Down Expand Up @@ -502,11 +503,11 @@ def write_params(group):
paramdescr,
group.to_dict()['name'] +
".abstract_parameters.push_back(${configname}Config::AbstractParamDescriptionConstPtr(new ${configname}Config::ParamDescription<${ctype}>(\"${name}\", \"${type}\", ${level}, "
"\"${description}\", \"${edit_method}\", &${configname}Config::${name})));", param)
"\"${description}\", \"${edit_method}\", \"${enable_if}\", &${configname}Config::${name})));", param)
self.appendline(
paramdescr,
"__param_descriptions__.push_back(${configname}Config::AbstractParamDescriptionConstPtr(new ${configname}Config::ParamDescription<${ctype}>(\"${name}\", \"${type}\", ${level}, "
"\"${description}\", \"${edit_method}\", &${configname}Config::${name})));", param)
"\"${description}\", \"${edit_method}\", \"${enable_if}\", &${configname}Config::${name})));", param)

for g in group.groups:
write_params(g)
Expand Down
11 changes: 6 additions & 5 deletions src/dynamic_reconfigure/parameter_generator_catkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def add_group(self, name, type="", state=True):
self.groups.append(group)
return group

def add(self, name, paramtype, level, description, default=None, min=None, max=None, edit_method=""):
def add(self, name, paramtype, level, description, default=None, min=None, max=None, edit_method="", enable_if=""):
newparam = {
'name': name,
'type': paramtype,
Expand All @@ -138,6 +138,7 @@ def add(self, name, paramtype, level, description, default=None, min=None, max=N
'srcline': inspect.currentframe().f_back.f_lineno,
'srcfile': inspect.getsourcefile(inspect.currentframe().f_back.f_code),
'edit_method': edit_method,
'enable_if': enable_if,
}
if (paramtype == str_t or paramtype == bool_t) and (max is not None or min is not None):
raise Exception(
Expand Down Expand Up @@ -287,8 +288,8 @@ def enum(self, constants, description):
return repr({'enum': constants, 'enum_description': description})

# Wrap add and add_group for the default group
def add(self, name, paramtype, level, description, default=None, min=None, max=None, edit_method=""):
self.group.add(name, paramtype, level, description, default, min, max, edit_method)
def add(self, name, paramtype, level, description, default=None, min=None, max=None, edit_method="", enable_if=""):
self.group.add(name, paramtype, level, description, default, min, max, edit_method, enable_if)

def add_group(self, name, type="", state=True):
return self.group.add_group(name, type=type, state=state)
Expand Down Expand Up @@ -481,11 +482,11 @@ def write_params(group):
paramdescr,
group.to_dict()['name'] +
".abstract_parameters.push_back(${configname}Config::AbstractParamDescriptionConstPtr(new ${configname}Config::ParamDescription<${ctype}>(\"${name}\", \"${type}\", ${level}, "
"\"${description}\", \"${edit_method}\", &${configname}Config::${name})));", param)
"\"${description}\", \"${edit_method}\", \"${enable_if}\", &${configname}Config::${name})));", param)
self.appendline(
paramdescr,
"__param_descriptions__.push_back(${configname}Config::AbstractParamDescriptionConstPtr(new ${configname}Config::ParamDescription<${ctype}>(\"${name}\", \"${type}\", ${level}, "
"\"${description}\", \"${edit_method}\", &${configname}Config::${name})));", param)
"\"${description}\", \"${edit_method}\", \"${enable_if}\", &${configname}Config::${name})));", param)

for g in group.groups:
write_params(g)
Expand Down
7 changes: 4 additions & 3 deletions templates/ConfigType.h.template
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ namespace ${pkgname}
{
public:
AbstractParamDescription(std::string n, std::string t, uint32_t l,
std::string d, std::string e)
std::string d, std::string e, std::string ei)
{
name = n;
type = t;
level = l;
description = d;
edit_method = e;
enable_if = ei;
}

virtual void clamp(${configname}Config &config, const ${configname}Config &max, const ${configname}Config &min) const = 0;
Expand All @@ -64,8 +65,8 @@ namespace ${pkgname}
{
public:
ParamDescription(std::string a_name, std::string a_type, uint32_t a_level,
std::string a_description, std::string a_edit_method, T ${configname}Config::* a_f) :
AbstractParamDescription(a_name, a_type, a_level, a_description, a_edit_method),
std::string a_description, std::string a_edit_method, std::string a_enable_if, T ${configname}Config::* a_f) :
AbstractParamDescription(a_name, a_type, a_level, a_description, a_edit_method, a_enable_if),
field(a_f)
{}

Expand Down