Skip to content

Commit 1fa3689

Browse files
committed
removed a bit the nesting
1 parent d7c8557 commit 1fa3689

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/compas_fab/robots/robot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def merge_group_with_full_configuration(self, group_configuration, full_configur
460460
if not len(group_configuration.joint_names):
461461
group_configuration.joint_names = self.get_configurable_joint_names(group)
462462

463-
full_configuration, full_configuration_scaled = self._check_full_configuration_and_scale(full_configuration) # adds joint_names to full_configuration and makes copy
463+
full_configuration = self._check_full_configuration_and_scale(full_configuration)[0] # adds joint_names to full_configuration and makes copy
464464

465465
full_joint_state = dict(zip(full_configuration.joint_names, full_configuration.values))
466466
group_joint_state = dict(zip(group_configuration.joint_names, group_configuration.values))

src/compas_fab/robots/semantics.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ def __get_group_link_names(self, group):
6969
link_names.append(name)
7070
return link_names
7171

72+
def __get_group_elem_by_name(self, group_name):
73+
for group_elem in self.root.findall('group'):
74+
if group_elem.attrib['name'] == group_name:
75+
return group_name
76+
7277
def __get_group_joint_names(self, group):
7378
joint_names = []
7479
for link in group.findall('link'):
@@ -86,12 +91,11 @@ def __get_group_joint_names(self, group):
8691
for subgroup in group.findall('group'):
8792
if subgroup.attrib['name'] != group.attrib['name']:
8893
# find group element at top level
89-
for top_group_elem in self.root.findall('group'):
90-
if top_group_elem.attrib['name'] == subgroup.attrib['name']:
91-
subgroup_joint_names = self.__get_group_joint_names(top_group_elem)
92-
for name in subgroup_joint_names:
93-
if name not in joint_names:
94-
joint_names.append(name)
94+
top_group_elem = self.__get_group_elem_by_name(subgroup.attrib['name'])
95+
subgroup_joint_names = self.__get_group_joint_names(top_group_elem)
96+
for name in subgroup_joint_names:
97+
if name not in joint_names:
98+
joint_names.append(name)
9599
return joint_names
96100

97101
def __source_attributes(self):

0 commit comments

Comments
 (0)