Skip to content

Commit 28638ad

Browse files
committed
links now have .number attribute
unique, contiguous
1 parent 66f7b00 commit 28638ad

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

roboticstoolbox/robot/ERobot.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,11 @@ def __init__(
125125

126126
# check all the incoming ELink objects
127127
n = 0
128-
link_number = 0
129-
for link in links:
128+
for k, link in enumerate(links):
130129
# if link has no name, give it one
131130
if link.name is None:
132-
link.name = f"link-{link_number}"
133-
link_number += 1
131+
link.name = f"link-{k}"
132+
link.number = k
134133

135134
# put it in the link dictionary, check for duplicates
136135
if link.name in self._linkdict:
@@ -206,7 +205,7 @@ def __init__(
206205

207206
# assign the joint indices
208207
if all([link.jindex is None for link in links]):
209-
208+
# no joints have an index
210209
jindex = [0] # "mutable integer" hack
211210

212211
def visit_link(link, jindex):
@@ -223,7 +222,7 @@ def visit_link(link, jindex):
223222
self.base_link, lambda link: visit_link(link, jindex))
224223

225224
elif all([link.jindex is not None for link in links if link.isjoint]):
226-
# jindex set on all, check they are unique and sequential
225+
# jindex set on all, check they are unique and contiguous
227226
if checkjindex:
228227
jset = set(range(self._n))
229228
for link in links:
@@ -285,7 +284,7 @@ def __str__(self):
285284
Column("parent", headalign="^", colalign="<"),
286285
Column("ETS", headalign="^", colalign="<"),
287286
border="thin")
288-
for k, link in enumerate(self):
287+
for link in self:
289288
color = "" if link.isjoint else "<<blue>>"
290289
ee = "@" if link in self.ee_links else ""
291290
ets = link.ets()
@@ -305,7 +304,7 @@ def __str__(self):
305304
else:
306305
jname = ''
307306
table.row(
308-
k,
307+
link.number,
309308
color + ee + link.name,
310309
jname,
311310
parent_name,

0 commit comments

Comments
 (0)