Skip to content

Commit f3bc139

Browse files
committed
remapped joints, joint_set
1 parent a443cb3 commit f3bc139

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

roboticstoolbox/robot/ETS.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def _repr_pretty_(self, p, cycle):
188188
"""
189189
print(self.__str__())
190190

191-
def joints(self) -> List[int]: # Returns a list of ET's joint_idx
191+
def joint_idx(self) -> List[int]:
192192
"""
193193
Get index of joint transforms
194194
@@ -200,12 +200,29 @@ def joints(self) -> List[int]: # Returns a list of ET's joint_idx
200200
201201
>>> from roboticstoolbox import ET
202202
>>> e = ET.Rz() * ET.tx(1) * ET.Rz() * ET.tx(1)
203-
>>> e.joints()
203+
>>> e.joint_idx()
204204
205205
"""
206206
return where([e.isjoint for e in self])[0]
207207

208-
def jointset(self) -> Set[int]: #
208+
def joints(self) -> List[ET]:
209+
"""
210+
Get a list of the variable ETs with this ETS
211+
212+
:return: list of ETs that are joints
213+
214+
Example:
215+
216+
.. runblock:: pycon
217+
218+
>>> from roboticstoolbox import ET
219+
>>> e = ET.Rz() * ET.tx(1) * ET.Rz() * ET.tx(1)
220+
>>> e.joints()
221+
222+
"""
223+
return [e for e in self if e.isjoint]
224+
225+
def jindex_set(self) -> Set[int]: #
209226
"""
210227
Get set of joint indices
211228
@@ -219,7 +236,7 @@ def jointset(self) -> Set[int]: #
219236
>>> e = ET.Rz(jindex=1) * ET.tx(jindex=2) * ET.Rz(jindex=1) * ET.tx(1)
220237
>>> e.jointset()
221238
"""
222-
return set([self[j].jindex for j in self.joints()]) # type: ignore
239+
return set([self[j].jindex for j in self.joint_idx()]) # type: ignore
223240

224241
@cached_property
225242
def jindices(self) -> ndarray:
@@ -298,7 +315,9 @@ def structure(self) -> str:
298315
>>> e.structure
299316
300317
"""
301-
return "".join(["R" if self.data[i].isrotation else "P" for i in self.joints()])
318+
return "".join(
319+
["R" if self.data[i].isrotation else "P" for i in self.joint_idx()]
320+
)
302321

303322
@property
304323
def n(self) -> int:
@@ -420,7 +439,7 @@ def split(self):
420439
segments = []
421440
start = 0
422441

423-
for j, k in enumerate(self.joints()):
442+
for j, k in enumerate(self.joint_idx()):
424443
ets_j = self.data[start : k + 1]
425444
start = k + 1
426445
segments.append(ets_j)
@@ -610,7 +629,7 @@ def __init__(
610629
self._auto_jindex = False
611630

612631
# Check if jindices are set
613-
joints = [self[j] for j in self.joints()]
632+
joints = self.joints()
614633

615634
# Number of joints with a jindex
616635
jindices = 0
@@ -1497,7 +1516,7 @@ def __init__(
14971516
self._auto_jindex = False
14981517

14991518
# Check if jindices are set
1500-
joints = [self[j] for j in self.joints()]
1519+
joints = self.joints()
15011520

15021521
# Number of joints with a jindex
15031522
jindices = 0
@@ -1772,7 +1791,7 @@ def jacob0(
17721791

17731792
j = 0
17741793
J = zeros((3, self.n))
1775-
etjoints = self.joints()
1794+
etjoints = self.joint_idx()
17761795

17771796
if not all(array([self[i].jindex for i in etjoints])):
17781797
# not all joints have a jindex it is required, set them

tests/test_ETS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def test_jointset(self):
415415
ans = set((0, 1, 2))
416416

417417
r = a + b + c + d
418-
nt.assert_equal(r.jointset(), ans)
418+
nt.assert_equal(r.jindex_set(), ans)
419419

420420
def test_split(self):
421421
deg = np.pi / 180

tests/test_ETS2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def test_jointset(self):
271271
ans = set((0, 1, 2))
272272

273273
r = a + b + c + d
274-
nt.assert_equal(r.jointset(), ans)
274+
nt.assert_equal(r.jindex_set(), ans)
275275

276276
def test_split(self):
277277
deg = np.pi / 180

0 commit comments

Comments
 (0)