Skip to content

Commit eeedeae

Browse files
committed
Fix #366 symbolic printing handled
1 parent 48e97d3 commit eeedeae

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

roboticstoolbox/robot/DHRobot.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ def angle(theta, fmt=None):
205205
else:
206206
return str(theta * deg) + "\u00b0"
207207

208+
def format_attr(attr) -> str:
209+
if isinstance(attr, float):
210+
return f"{attr:.4g}"
211+
else:
212+
return str(attr)
213+
208214
has_qlim = any([link.qlim is not None for link in self])
209215
if has_qlim:
210216
qlim_columns = [
@@ -249,6 +255,7 @@ def angle(theta, fmt=None):
249255
*qlim_columns,
250256
border=border,
251257
)
258+
252259
for j, L in enumerate(self):
253260
if has_qlim:
254261
if L.isprismatic:
@@ -259,11 +266,19 @@ def angle(theta, fmt=None):
259266
ql = []
260267
if L.isprismatic:
261268
table.row(
262-
angle(L.theta), qstr(j, L), f"{L.a:.4g}", angle(L.alpha), *ql
269+
angle(L.theta),
270+
qstr(j, L),
271+
format_attr(L.a),
272+
angle(L.alpha),
273+
*ql,
263274
)
264275
else:
265276
table.row(
266-
qstr(j, L), f"{L.d:.4g}", f"{L.a:.4g}", angle(L.alpha), *ql
277+
qstr(j, L),
278+
format_attr(L.d),
279+
format_attr(L.a),
280+
angle(L.alpha),
281+
*ql,
267282
)
268283

269284
s += str(table)

0 commit comments

Comments
 (0)