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

Allow nested map definitions #191

Open
Kotochleb opened this issue Apr 3, 2024 · 3 comments
Open

Allow nested map definitions #191

Kotochleb opened this issue Apr 3, 2024 · 3 comments

Comments

@Kotochleb
Copy link

Currently, the library allows only top level map definitions. Something that would be nice is the option to create parameters in a following way.

With this yaml:

my_node:
  my_params:
    params_to_be_mapped: {
      type: string_array,
    }
    __map_params_to_mapped:
      in_map_param: {
        type: bool,
      }

When attempting to do so, the current Jinja template will create the following code:

# declare any new dynamic parameters
for value_1 in updated_params.params_to_mapped:
  updated_params.my_params.add_entry(value_1)

# ...

for value_1 in updated_params.params_to_mapped:
  param_name = f"{self.prefix_}my_params.{value_1}.in_map_param"

# ...

# declare and set all dynamic parameters
for value_1 in updated_params.params_to_mapped:
  updated_params.my_params.add_entry(value_1)

While the expected output is:

# declare any new dynamic parameters
for value_1 in updated_params.my_params.params_to_mapped:
  updated_params.my_params.add_entry(value_1)

# ...

for value_1 in updated_params.my_params.params_to_mapped:
  param_name = f"{self.prefix_}my_params.{value_1}.in_map_param"

# ...

# declare and set all dynamic parameters
for value_1 in updated_params.my_params.params_to_mapped:
  updated_params.my_params.add_entry(value_1)

Namespace of my_params is not taken into account in for loops of the mapped values.

Topic initially started in #183.

@BrunoB81HK
Copy link
Contributor

Is there any plan to implement this feature? This would be very useful since a mapped parameters is not necessarily a global one.

@pac48 suggested to use the following key format and I think this is the way to go: __map_my_params.params_to_mapped

@pac48
Copy link
Collaborator

pac48 commented Apr 18, 2024

@BrunoB81HK I am working on a branch here https://github.com/PickNikRobotics/generate_parameter_library/tree/pr-allow-mapped-sub-parameter but it is not ready yet.

@BrunoB81HK
Copy link
Contributor

@pac48 Great! Thanks a lot for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants