Skip to content

Fix: allow nested param names #251

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

Open
wants to merge 2 commits into
base: main
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
13 changes: 7 additions & 6 deletions example/src/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ admittance_controller:
gt_eq<>: [ 0.0001 ]
__map_joints:
__map_dof_names:
nested_deep:
type: double
default_value: 1.0
description: "test deep nested map params"
validation:
gt_eq<>: [ 0.0001 ]
nested:
nested_deep:
type: double
default_value: 1.0
description: "test deep nested map params"
validation:
gt_eq<>: [ 0.0001 ]

pid:
rate:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def int_to_integer_str(value: str):

def get_dynamic_parameter_field(yaml_parameter_name: str):
tmp = yaml_parameter_name.split('.')
parameter_field = tmp[-1]
return parameter_field
index = tmp.index(next(val for val in reversed(tmp) if is_mapped_parameter(val)))
return ".".join(tmp[index + 1:])


def get_dynamic_mapped_parameter(yaml_parameter_name: str):
Expand All @@ -115,9 +115,8 @@ def get_dynamic_mapped_parameter(yaml_parameter_name: str):

def get_dynamic_struct_name(yaml_parameter_name: str):
tmp = yaml_parameter_name.split('.')
num_nested = sum([is_mapped_parameter(val) for val in tmp])
struct_name = tmp[: -(num_nested + 1)]
return '.'.join(struct_name)
index = tmp.index(next(val for val in tmp if is_mapped_parameter(val)))
return tmp[index - 1] if index > 0 else ''


def get_dynamic_parameter_name(yaml_parameter_name: str):
Expand Down Expand Up @@ -806,7 +805,7 @@ def parse_params(self, name, value, nested_name_list):
var = VariableDeclaration(code_gen_variable)

# check if runtime parameter
is_runtime_parameter = is_mapped_parameter(self.struct_tree.struct_name)
is_runtime_parameter = any(is_mapped_parameter(item) for item in nested_name_list)

if is_runtime_parameter:
declare_parameter_set = SetRuntimeParameter(param_name, code_gen_variable)
Expand Down