Skip to content

No way to reference non top-level keys in parameters map #278

@solonovamax

Description

@solonovamax

There is no way to reference a non top-level key in a parameter map

Here is an example:

example:
  nested:
    entries:
      type: string_array

    __map_entries:
      value:
        type: string

this does not properly find the entries key, and instead generates code that looks like the following:

// error: no member named 'entries' in 'example::Params'
for (const auto & value_1 : updated_params.entries) {
//                          ~~~~~~~~~~~~~~ ^

    /* ... */
}

the following also does not work:

example:
  nested:
    keys:
      type: string_array

    __map_nested.keys:
      value:
        type: string

as it will generate code that looks like the following:

struct Params {
    struct Nested {
        std::vector<std::string> keys;
// error: expected member name or ';' after declaration specifiers
        struct MapNested.Keys {
//      ~~~~~~~~~~~~~~~~^
            std::string value;
        };
// error: expected '>'
// error: expected member name or ';' after declaration specifiers
        std::map<std::string, MapNested.Keys> nested_keys_map;
//                                     ^
    } nested;
    // for detecting if the parameter struct has been updated
    rclcpp::Time __stamp;
};

/* ... */

// error: invalid range expression of type 'struct Nested'; no viable 'begin' function available
for (const auto & value_1 : updated_params.nested) {
//                        ^ ~~~~~~~~~~~~~~

// error: no member named '__map_nested' in 'example::Params::Nested'
    auto& entry = updated_params.nested.__map_nested.nested_map[value_1];
//                ~~~~~~~~~~~~~~~~~~~~~ ^

    /* ... */
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions