8000 change Link str method to show joint variable · ctc-eng/robotics-toolbox-python@777d733 · GitHub
[go: up one dir, main page]

Skip to content

Commit 777d733

Browse files
committed
change Link str method to show joint variable
and offset more obviously
1 parent 8f7084c commit 777d733

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

roboticstoolbox/robot/Link.py

Lines changed: 7 additions & 6 deletions
< 8000 /tr>
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def __init__(
8585
self.alpha = alpha
8686
self.a = a
8787
self.mdh = mdh
88+
self.id = None
8889
self.offset = offset
8990

9091
self.flip = flip
@@ -126,13 +127,13 @@ def __add__(self, L):
126127
def __str__(self):
127128

128129
if not self.sigma:
129-
s = "Revolute theta={: .2f} d={: .2f} a={: .2f} " \
130-
"alpha={: .2f} offset={: .2f}".format(
131-
self.theta, self.d, self.a, self.alpha, self.offset)
130+
s = "Revolute theta=q{} +{: .2f}, d={: .2f}, a={: .2f}, " \
131+
"alpha={: .2f}".format(
132+
self.id, self.offset, self.d, self.a, self.alpha)
132133
else:
133-
s = "Prismatic theta={: .2f} d={: .2f} a={: .2f} " \
134-
"alpha={: .2f} offset={: .2f}".format(
135-
self.theta, self.d, self.a, self.alpha, self.offset)
134+
s = "Prismatic theta={: .2f}, d=q{} +{: .2f}, a={: .2f}, " \
135+
"alpha={: .2f}".format(
136+
self.theta, self.id, self.offset, self.a, self.alpha, )
136137

137138
return s
138139

roboticstoolbox/robot/SerialLink.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ def __init__(
8080
if isinstance(L[i], Link):
8181
self._links.append(L[i])
8282
self._n += 1
83+
L[i].id = self._n
8384

8485
elif isinstance(L[i], SerialLink):
8586
for j in range(L[i].n):
8687
self._links.append(L[i].links[j])
8788
self._n += 1
89+
L[i].id = self._n
8890

8991
else:
9092
raise TypeError("Input can be only Link or SerialLink")

0 commit comments

Comments
 (0)
0