fixup joint index assignment code
@@ -97,6 +97,8 @@ class ERobot(Robot):
n = 0
for link in elinks:
if isinstance(link, ELink):
+ if link.name in self._linkdict:
+ raise ValueError(f'link name {link.name} is not unique')
self._linkdict[link.name] = link
else:
raise TypeError("Input can be only ELink")
@@ -175,17 +177,18 @@ class ERobot(Robot):
self.dfs_links(
self.base_link, lambda link: visit_link(link, jindex))
- elif all([link.jindex is not None for link in elinks]):
+ elif all([link.jindex is not None for link in elinks if link.isjoint]):
# jindex set on all, check they are unique and sequential
jset = set(range(self._n))
for link in elinks:
- if link.jindex not in jset:
+ if link.isjoint and link.jindex not in jset:
raise ValueError(
- 'joint index {link.jindex} was '
+ f'joint index {link.jindex} was '
'repeated or out of range')
jset -= set([link.jindex])
if len(jset) > 0: # pragma nocover # is impossible
- raise ValueError('joints {jset} were not assigned')
+ raise ValueError(f'joints {jset} were not assigned')
+ orlinks = elinks
else:
# must be a mixture of ELinks with/without jindex
raise ValueError(
