Skip to content

Conversation

@MarqRazz
Copy link
Contributor

@MarqRazz MarqRazz commented Jul 17, 2024

This PR makes it so the parameter_listener can refresh it's copy of parameters with ones specified in a yaml dictionary and would close #208.

To load and the get the parameters

        self.param_listener = my_param_namespace.ParamListener(self.node)
        path_to_config = os.path.dirname(__file__) + '/config/my_config_file.yaml'
        with open(path_to_config) as file:
            configParamsFromYaml = yaml.safe_load(file)['my_param_namespace']['ros__parameters']

        self.param_listener.set_params_from_dict(configParamsFromYaml)
        self.test_params = self.param_listener.get_params()

@MarqRazz
Copy link
Contributor Author

Note this design was heavily influenced by rclpy.parameter.py's unpack_parameter_dict()

What do you think about supporting the yaml loading like they do in parameter_dict_from_yaml_file(). I tried to use this functionality but it's not in Humble and returns a Dict[str, ParameterMsg] where generate_parameter's update() takes a list of rclpy.parameter.Parameter's. Personally I think it's fine for the user to have to load the dictionary from the correct namespace with yaml.safe_load(file)['my_param_namespace']['ros__parameters']

@MarqRazz
Copy link
Contributor Author

@pac48 do you have any thoughts about this approach? Is there anything I can do to help get this across the finish line?

@pac48
Copy link
Contributor

pac48 commented Jul 24, 2024

@MarqRazz I added a small comment, otherwise looks good.

@MarqRazz
Copy link
Contributor Author

How does that look?

@MarqRazz
Copy link
Contributor Author

MarqRazz commented Aug 1, 2024

@pac48 can we run the tests?

@pac48 pac48 merged commit 3da6c01 into PickNikRobotics:main Aug 1, 2024
@MarqRazz MarqRazz deleted the set_param_from_dict branch August 1, 2024 17:02
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

Successfully merging this pull request may close these issues.

Set parameters from YAML dictionary.

2 participants