diff --git a/example/config/implementation.yaml b/example/config/implementation.yaml index 11a3f38..4cd1ba9 100644 --- a/example/config/implementation.yaml +++ b/example/config/implementation.yaml @@ -12,7 +12,8 @@ admittance_controller: "happy" elbow_joint: - weight: 2.0 + x: + weight: 2.0 pid: shoulder_pan_joint: diff --git a/example/src/parameters.yaml b/example/src/parameters.yaml index e0f51fa..31e7e61 100644 --- a/example/src/parameters.yaml +++ b/example/src/parameters.yaml @@ -25,14 +25,15 @@ admittance_controller: } __map_joints: - weight: { - type: double, - default_value: 1.0, - description: "map parameter without struct name", - validation: { - gt<>: [0.0], + __map_dof_names: + weight: { + type: double, + default_value: 1.0, + description: "map parameter without struct name", + validation: { + gt<>: [0.0], + } } - } nested_dynamic: __map_joints: diff --git a/example_python/config/implementation.yaml b/example_python/config/implementation.yaml index 11a3f38..4cd1ba9 100644 --- a/example_python/config/implementation.yaml +++ b/example_python/config/implementation.yaml @@ -12,7 +12,8 @@ admittance_controller: "happy" elbow_joint: - weight: 2.0 + x: + weight: 2.0 pid: shoulder_pan_joint: diff --git a/example_python/generate_parameter_module_example/parameters.yaml b/example_python/generate_parameter_module_example/parameters.yaml index 3cff6d5..1440e58 100644 --- a/example_python/generate_parameter_module_example/parameters.yaml +++ b/example_python/generate_parameter_module_example/parameters.yaml @@ -33,14 +33,15 @@ admittance_controller: } __map_joints: - weight: { - type: double, - default_value: 1.0, - description: "map parameter without struct name", - validation: { - gt<>: [0.0], + __map_dof_names: + weight: { + type: double, + default_value: 1.0, + description: "map parameter without struct name", + validation: { + gt<>: [0.0], + } } - } nested_dynamic: __map_joints: diff --git a/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/cpp/declare_runtime_parameter b/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/cpp/declare_runtime_parameter index 11f1d01..244e595 100644 --- a/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/cpp/declare_runtime_parameter +++ b/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/cpp/declare_runtime_parameter @@ -5,7 +5,7 @@ for (const auto & value_{{loop.index}} : updated_params.{{mapped_param}}) { {% if struct_name != "" %} auto& entry = {{param_struct_instance}}.{{struct_name}}{% for map in parameter_map%}.{{map}}[value_{{loop.index}}]{% endfor %}; {% else %} -auto& entry = {{param_struct_instance}}.{% for map in parameter_map%}{{map}}[value_{{loop.index}}]{% endfor %}; +auto& entry = {{param_struct_instance}}{% for map in parameter_map%}.{{map}}[value_{{loop.index}}]{% endfor %}; {% endif -%} std::string value = fmt::format("{%- for mapped_param in mapped_params -%}{% if loop.index == 1 %}{}{% else %}.{}{% endif -%} {%- endfor -%}", {%- for mapped_param in mapped_params -%}{% if loop.index == 1 %} value_{{loop.index}}{% else %}, value_{{loop.index}}{% endif -%} {%- endfor %}); diff --git a/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/cpp/update_runtime_parameter b/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/cpp/update_runtime_parameter index bdd59ad..b4cd4e3 100644 --- a/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/cpp/update_runtime_parameter +++ b/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/cpp/update_runtime_parameter @@ -17,7 +17,7 @@ if (param.get_name() == param_name) { {% if struct_name != "" %} updated_params.{{struct_name}}{% for map in parameter_map%}.{{map}}[value_{{loop.index}}]{% endfor %}.{{parameter_field}} = param.{{parameter_as_function}}; {% else %} -updated_params.{% for map in parameter_map%}{{map}}[value_{{loop.index}}]{% endfor %}.{{parameter_field}} = param.{{parameter_as_function}}; +updated_params{% for map in parameter_map%}.{{map}}[value_{{loop.index}}]{% endfor %}.{{parameter_field}} = param.{{parameter_as_function}}; {% endif -%} RCLCPP_DEBUG_STREAM(logger_, param.get_name() << ": " << param.get_type_name() << " = " << param.value_to_string()); {% endfilter -%} diff --git a/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/python/declare_runtime_parameter b/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/python/declare_runtime_parameter index 0f7b4c8..96c48f7 100644 --- a/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/python/declare_runtime_parameter +++ b/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/python/declare_runtime_parameter @@ -7,11 +7,11 @@ for value_{{loop.index}} in updated_params.{{mapped_param}}: {% if struct_name != "" %} {{param_struct_instance}}.{{struct_name}}{% for map in parameter_map%}.add_entry(value_{{loop.index}}){% endfor %} entry = {{param_struct_instance}}.{{struct_name}}{% for map in parameter_map%}.get_entry(value_{{loop.index}}){% endfor %} -param_name = f"{self.prefix_}{{struct_name}}{% for map in parameter_map%}.{value_{{loop.index}}}{% endfor %}.{{parameter_field}}" +param_name = f"{self.prefix_}{{struct_name}}.{% for map in parameter_map%}{value_{{loop.index}}}.{% endfor %}{{parameter_field}}" {% else %} {{param_struct_instance}}{% for map in parameter_map%}.add_entry(value_{{loop.index}}){% endfor %} entry = {{param_struct_instance}}{% for map in parameter_map%}.get_entry(value_{{loop.index}}){% endfor %} -param_name = f"{self.prefix_}{% for map in parameter_map%}{value_{{loop.index}}}{% endfor %}.{{parameter_field}}" +param_name = f"{self.prefix_}{% for map in parameter_map%}{value_{{loop.index}}}.{% endfor %}{{parameter_field}}" {% endif -%} if not self.node_.has_parameter(self.prefix_ + param_name): {%- filter indent(width=4) %} diff --git a/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/python/update_runtime_parameter b/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/python/update_runtime_parameter index 30f34e7..195fb78 100644 --- a/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/python/update_runtime_parameter +++ b/generate_parameter_library_py/generate_parameter_library_py/jinja_templates/python/update_runtime_parameter @@ -4,7 +4,11 @@ for value_{{loop.index}} in updated_params.{{mapped_param}}: {%- endfilter -%} {% endfor -%} {%- filter indent(width=4*(1+mapped_params|length)) %} -param_name = f"{self.prefix_}{{struct_name}}{% for map in parameter_map%}.{value_{{loop.index}}}{% endfor %}.{{parameter_field}}" +{% if struct_name != "" %} +param_name = f"{self.prefix_}{{struct_name}}{% for map in parameter_map%}{value_{{loop.index}}}.{% endfor %}{{parameter_field}}" +{% else %} +param_name = f"{self.prefix_}{% for map in parameter_map%}{value_{{loop.index}}}.{% endfor %}{{parameter_field}}" +{% endif -%} if param.name == param_name: {%- filter indent(width=4) %} {% if parameter_validations|length -%}