8000 str method · navrobot/robotics-toolbox-python@0ce1bc0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0ce1bc0

Browse files
committed
str method
put tool/base in separate table named configuration is nice, column per joint, headers, handle symbolic values
1 parent a86a932 commit 0ce1bc0

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

roboticstoolbox/models/DH/Puma560.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def __init__(self, symbolic=False):
169169
L,
170170
name="Puma 560",
171171
manufacturer="Unimation",
172-
keywords=('dynamics', 'symbolic'),
172+
keywords=('dynamics', 'symbolic', 'mesh'),
173173
symbolic=symbolic,
174174
meshdir="meshes/UNIMATE/puma560"
175175
)

roboticstoolbox/robot/DHRobot.py

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -180,28 +180,41 @@ def angle(theta):
180180

181181
s = str(table)
182182

183-
table = ANSITable(
184-
Column("", colalign=">"),
185-
Column("", colalign="<"), border="thin", header=False)
186-
if self._base is not None:
187-
table.row(
188-
"base", self._base.printline(
189-
orient="rpy/xyz", fmt="{:.2g}", file=None))
190-
if self._tool is not None:
191-
table.row(
192-
"tool", self._tool.printline(
193-
orient="rpy/xyz", 8000 fmt="{:.2g}", file=None))
194-
195-
for name, q in self._configdict.items():
196-
qlist = []
197-
for i, L in enumerate(self):
198-
if L.isprismatic():
199-
qlist.append(f"{q[i]:.3g}")
200-
else:
201-
qlist.append(f"{q[i] * deg:.3g}\u00b0")
202-
table.row(name, ', '.join(qlist))
183+
# show tool and base
184+
if self._tool is not None or self._tool is not None:
185+
table = ANSITable(
186+
Column("", colalign=">"),
187+
Column("", colalign="<"),
188+
border="thin", header=False)
189+
if self._base is not None:
190+
table.row(
191+
"base", self._base.printline(
192+
orient="rpy/xyz", fmt="{:.2g}", file=None))
193+
if self._tool is not None:
194+
table.row(
195+
"tool", self._tool.printline(
196+
orient="rpy/xyz", fmt="{:.2g}", file=None))
197+
s += "\n" + str(table)
203198

204-
return s + "\n" + str(table)
199+
# show named configurations
200+
if len(self._configdict) > 0:
201+
table = ANSITable(
202+
Column("name", colalign=">"),
203+
*[Column(f"q{j:d}", colalign="<", headalign="<") for j in range(self.n)],
204+
border="thin")
205+
206+
for name, q in self._configdict.items():
207+
qlist = []
208+
for i, L in enumerate(self):
209+
if L.isprismatic():
210+
qlist.append(f"{q[i]:.3g}")
211+
else:
212+
qlist.append(angle(q[i]))
213+
table.row(name, *qlist)
214+
215+
s += "\n" + str(table)
216+
217+
return s
205218

206219

207220
def __add__(self, L):

0 commit comments

Comments
 (0)
0