Skip to content

Commit

Permalink
only make one get_parameter_value call in ros2 param dump
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Chen <[email protected]>
  • Loading branch information
ihasdapie committed Jun 16, 2022
1 parent efcc246 commit b514fd5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ros2param/ros2param/verb/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ def add_arguments(self, parser, cli_name): # noqa: D102
help='DEPRECATED: Does nothing.')

@staticmethod
def get_parameter_value(node, node_name, param):
def get_parameter_values(node, node_name, params):
response = call_get_parameters(
node=node, node_name=node_name,
parameter_names=[param])
parameter_names=params)

# requested parameter not set
if not response.values:
return '# Parameter not set'

# extract type specific value
return get_value(parameter_value=response.values[0])
return [get_value(parameter_value=i) for i in response.values]

def insert_dict(self, dictionary, key, value):
split = key.split(PARAMETER_SEPARATOR_STRING, 1)
Expand Down Expand Up @@ -93,9 +93,10 @@ def main(self, *, args): # noqa: D102

# retrieve values
response = call_list_parameters(node=node, node_name=absolute_node_name)
response = sorted(response)
parameter_values = self.get_parameter_values(node, absolute_node_name, response)

for param_name in sorted(response):
pval = self.get_parameter_value(node, absolute_node_name, param_name)
for param_name, pval in zip(response, parameter_values):
self.insert_dict(
yaml_output[node_name.full_name]['ros__parameters'], param_name, pval)

Expand Down

0 comments on commit b514fd5

Please sign in to comment.