Skip to content

Usage of set_params_from_dict fails #219

Closed
@Glonks

Description

@Glonks

When using the new feature to set params from a dict, the node fails with the following error:

NameError: name 'unpack_parameter_dict' is not defined

I think the error comes from here:

@staticmethod
def unpack_parameter_dict(namespace: str, parameter_dict: dict):
"""
Flatten a parameter dictionary recursively.
:param namespace: The namespace to prepend to the parameter names.
:param parameter_dict: A dictionary of parameters keyed by the parameter names
:return: A list of rclpy Parameter objects
"""
parameters = []
for param_name, param_value in parameter_dict.items():
full_param_name = namespace + param_name
# Unroll nested parameters
if isinstance(param_value, dict):
nested_params = unpack_parameter_dict(
namespace=full_param_name + rclpy.parameter.PARAMETER_SEPARATOR_STRING,
parameter_dict=param_value)
parameters.extend(nested_params)
else:
parameters.append(rclpy.parameter.Parameter(full_param_name, value=param_value))
return parameters
def set_params_from_dict(self, param_dict):
params_to_set = unpack_parameter_dict('', param_dict)

The method is not referred to via self, and so python fails to find it.

Testing locally, simply removing @staticmethod and adding self seems to solve the issue.

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