8000 move ETS splitting from ERobot to ETS · ctc-eng/robotics-toolbox-python@4b6d822 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b6d822

Browse files
committed
move ETS splitting from ERobot to ETS
1 parent 8e75dc3 commit 4b6d822

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

roboticstoolbox/robot/ERobot.py

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -946,33 +946,22 @@ class ERobot(BaseERobot):
946946

947947
def __init__(self, arg, **kwargs):
948948

949-
950949
if isinstance(arg, DHRobot):
951950
# we're passed a DHRobot object
952951
# TODO handle dynamic parameters if given
953952
arg = arg.ets()
954953

955-
link_number = 0
956954
if isinstance(arg, ETS):
957955
# we're passed an ETS string
958956
ets = arg
959957
links = []
960-
961958
# chop it up into segments, a link frame after every joint
962-
start = 0
963-
for j, k in enumerate(ets.joints()):
964-
ets_j = ets[start:k + 1]
965-
start = k + 1
966-
if j == 0:
967-
parent = None
968-
else:
969-
parent = links[-1]
959+
parent = None
960+
for j, ets_j in enumerate(arg.split()):
970961
elink = ELink(ets_j, parent=parent, name=f"link{j:d}")
962+
parent = elink
971963
links.append(elink)
972-
tail = arg[start:]
973-
if len(tail) > 0:
974-
elink = ELink(tail, parent=links[-1], name=f"link{j+1:d}")
975-
links.append(elink)
964+
976965
elif islistof(arg, ELink):
977966
links = arg
978967
else:
@@ -2114,22 +2103,13 @@ def __init__(self, arg, **kwargs):
21142103
# we're passed an ETS string
21152104
ets = arg
21162105
links = []
2117-
21182106
# chop it up into segments, a link frame after every joint
2119-
start = 0
2120-
for j, k in enumerate(ets.joints()):
2121-
ets_j = ets[start:k + 1]
2122-
start = k + 1
2123-
if j == 0:
2124-
parent = None
2125-
else:
2126-
parent = links[-1]
2107+
parent = None
2108+
for j, ets_j in enumerate(arg.split()):
21272109
elink = ELink2(ets_j, parent=parent, name=f"link{j:d}")
2110+
parent = elink
21282111
links.append(elink)
2129-
tail = arg[start:]
2130-
if len(tail) > 0:
2131-
elink = ELink2(tail, parent=links[-1], name=f"link{j+1:d}")
2132-
links.append(elink)
2112+
21332113
elif islistof(arg, ELink2):
21342114
links = arg
21352115
else:

roboticstoolbox/robot/ETS.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,25 @@ def eval(self, q=None, unit='rad'):
530530

531531
return T
532532

533+
def split(self):
534+
"""
535+
Split ETS into link segments
536+
537+
Returns a list of ETS, each one, apart from the last,
538+
ends with a variable ET.
539+
"""
540+
segments = []
541+
start = 0
542+
for j, k in enumerate(self.joints()):
543+
ets_j = self[start:k + 1]
544+
start = k + 1
545+
segments.append(ets_j)
546+
tail = self[start:]
547+
if len(tail) > 0:
548+
segments.append(tail)
549+
550+
return segments
551+
533552
def compile(self):
534553
"""
535554
Compile an ETS

0 commit comments

Comments
 (0)
0