-
Notifications
You must be signed in to change notification settings - Fork 60
Closed
Description
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
self.node = rclpy.create_node('my_test_node')
self.param_listener = my_params.ParamListener(self.node)
self.params = self.param_listener.get_params()
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:
my_manually_loaded_yaml_parameters = yaml.safe_load(file)['my_test_node']['ros__parameters']
print(my_manually_loaded_yaml_parameters['load_pose_list_from_file']) # print a parameter from the dictionaryIf 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.
self.node = rclpy.create_node('my_test_node')
self.param_listener = my_params.ParamListener(self.node)
path_to_test_config = os.path.dirname(__file__) + '/config/test_parameters_from_file.yaml'
# Update parameters from test config YAML file before fetching a copy.
with open(path_to_test_config, 'r') as file:
my_manually_loaded_yaml_parameters = yaml.safe_load(file)['my_test_node']['ros__parameters']
self.param_listener.update_internal_params(my_manually_loaded_yaml_parameters)
self.params = self.param_listener.get_params()@pac48 does this sound hard to implement?
Metadata
Metadata
Assignees
Labels
No labels