-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Set parameters from YAML dictionary. #208
Comments
I think it is possible. Here is an issue where we discussed doing the opposite (going from the struct to a dictionary) #155 I think something similar could be done for the use case you presented. Ideally, this can be implemented without modifying the code generator. |
I got things to set from a YAML config but it does not collapse the mapped dictionaries correctly so it fails to get the item as an object. path_to_test_config = os.path.dirname(__file__) + '/config/test_parameters_from_file.yaml'
# Load the parameters specific to the test Node
with open(path_to_test_config, 'r') as file:
configParams = yaml.safe_load(file)['my_test_node']['ros__parameters']
my_loaded_params = self.param_listener.get_params()
for p in configParams:
vars(my_loaded_params).update({p: configParams[p]})
print(vars(my_loaded_params).get(p))
self.param_listener.update_internal_params(my_loaded_params)
self.params = self.param_listener.get_params() The generate_parameter_library smash the parameter name down to and the Yaml dictionary is still a dictionary when loaded like I suggest. If you have suggestions on where to put this I'm all ears! |
@MarqRazz Can we schedule the meeting tomorrow at 11:30 instead of 11:00? |
I'm in the need of using generate_parameter_library to declare, set and update my parameters when launching/running my node but I also need the ability to control which values are loaded when testing.
When I test I create a ROS2 node, declare the ParamListener and then get my parameters but the problem is that nothing has set them so everything defaults. I would like the ability to get my parameters and then override them from a YAML dictionary
If I could update the parameters from a YAML file it would allow me to write test configs that I can use to check expected behavior.
@pac48 does this sound hard to implement?
The text was updated successfully, but these errors were encountered: