-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support nested mapped parameters (#166)
- Loading branch information
Showing
10 changed files
with
124 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
...ter_library_py/generate_parameter_library_py/jinja_templates/cpp/update_runtime_parameter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
for (const auto & value : updated_params.{{mapped_param}}){ | ||
{%- filter indent(width=4) %} | ||
{% for mapped_param in mapped_params -%} | ||
for (const auto & value_{{loop.index}} : updated_params.{{mapped_param}}) { | ||
{% endfor -%} | ||
{%- filter indent(width=4) -%} | ||
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 %}); | ||
auto param_name = fmt::format("{}{}.{}.{}", prefix_, "{{struct_name}}", value, "{{parameter_field}}"); | ||
if (param.get_name() == param_name) { | ||
{%- filter indent(width=4) %} | ||
{% if parameter_validations|length -%} | ||
{{parameter_validations-}} | ||
{% endif -%} | ||
updated_params.{{parameter_map}}[value].{{parameter_field}} = param.{{parameter_as_function}}; | ||
updated_params.{{struct_name}}{% for map in parameter_map%}.{{map}}[value_{{loop.index}}]{% endfor %}.{{parameter_field}} = param.{{parameter_as_function}}; | ||
RCLCPP_DEBUG_STREAM(logger_, param.get_name() << ": " << param.get_type_name() << " = " << param.value_to_string()); | ||
{% endfilter -%} | ||
} | ||
{% endfilter -%} | ||
{%- for mapped_param in mapped_params -%} | ||
} | ||
{% endfor -%} |
14 changes: 9 additions & 5 deletions
14
...library_py/generate_parameter_library_py/jinja_templates/python/declare_runtime_parameter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 8 additions & 4 deletions
12
..._library_py/generate_parameter_library_py/jinja_templates/python/update_runtime_parameter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
for value in updated_params.{{mapped_param}}: | ||
{%- filter indent(width=4) %} | ||
param_name = f"{self.prefix_}{{struct_name}}.{value}.{{parameter_field}}" | ||
{% for mapped_param in mapped_params -%} | ||
{%- filter indent(width=4*loop.index) %} | ||
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 param.name == param_name: | ||
{%- filter indent(width=4) %} | ||
{% if parameter_validations|length -%} | ||
{{parameter_validations-}} | ||
{% endif -%} | ||
updated_params.{{parameter_map}}[value].{{parameter_field}} = param.{{parameter_as_function}} | ||
updated_params.{{struct_name}}{% for map in parameter_map%}.get_entry(value_{{loop.index}}){% endfor %}.{{parameter_field}} = param.{{parameter_as_function}} | ||
self.logger_.debug(param.name + ": " + param.type_.name + " = " + str(param.value)) | ||
{% endfilter -%} | ||
{% endfilter -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters