Skip to content

Commit 60365b8

Browse files
committed
pretty print dynamic parameters
1 parent 4447fbe commit 60365b8

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

roboticstoolbox/robot/Robot.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
from pathlib import PurePath, PurePosixPath
1313
from scipy.optimize import minimize, Bounds, LinearConstraint
1414
from roboticstoolbox.tools.null import null
15+
from ansitable import ANSITable, Column
1516

1617
# TODO maybe this needs to be abstract
1718
# ikine functions need: fkine, jacobe, qlim methods from subclass
1819

1920
class Robot:
2021

22+
_color = True
23+
2124
def __init__(
2225
self,
2326
links,
@@ -200,17 +203,33 @@ def dyntable(self):
200203
"""
201204
Pretty print the dynamic parameters (Robot superclass)
202205
206+
The dynamic parameters are printed in a table, with one row per link.
207+
203208
Example:
204209
205210
.. runblock:: pycon
206211
212+
>>> import roboticstoolbox as rtb
213+
>>> robot = rtb.models.DH.Puma560()
214+
>>> robot.links[2].dyntable()
215+
207216
>>> import roboticstoolbox as rtb
208217
>>> robot = rtb.models.DH.Puma560()
209218
>>> robot.dyntable()
210219
"""
220+
table = ANSITable(
221+
Column("j", colalign=">", headalign="^"),
222+
Column("m", colalign="<", headalign="^"),
223+
Column("r", colalign="<", headalign="^"),
224+
Column("I", colalign="<", headalign="^"),
225+
Column("Jm", colalign="<", headalign="^"),
226+
Column("B", colalign="<", headalign="^"),
227+
Column("Tc", colalign="<", headalign="^"),
228+
Column("G", colalign="<", headalign="^"), border="thin")
229+
211230
for j, link in enumerate(self):
212-
print(f"Link {j:d}")
213-
link.dyntable(indent=4)
231+
table.row(link.name, *link._dyn2list())
232+
return str(table)
214233

215234
# --------------------------------------------------------------------- #
216235
@property
@@ -1021,7 +1040,7 @@ def cost(x, ub, lb, qm, N):
10211040
# --------------------------------------------------------------------- #
10221041

10231042
def friction(self, qd):
1024-
"""
1043+
r"""
10251044
Manipulator joint friction (Robot superclass)
10261045
10271046
:param qd: The joint velocities of the robot
@@ -1083,19 +1102,16 @@ def nofriction(self, coulomb=True, viscous=False):
10831102
"""
10841103
Remove manipulator joint friction (Robot superclass)
10851104
1086-
NFrobot = nofriction(coulomb, viscous) copies the robot and returns
1087-
a robot with the same parameters except, the Coulomb and/or viscous
1088-
friction parameter set to zero
1089-
1090-
NFrobot = nofriction(coulomb, viscous) copies the robot and returns
1091-
a robot with the same parameters except the Coulomb friction parameter
1092-
is set to zero
1093-
1094-
:param coulomb: if True, will set the coulomb friction to 0
1105+
:param coulomb: set the Coulomb friction to 0
10951106
:type coulomb: bool
1096-
1107+
:param viscous: set the viscous friction to 0
1108+
:type viscous: bool
10971109
:return: A copy of the robot with dynamic parameters perturbed
1098-
:rtype: DHRobot
1110+
:rtype: Robot subclass
1111+
1112+
``nofriction()`` copies the robot and returns
1113+
a robot with the same link parameters except the Coulomb and/or viscous
1114+
friction parameter are set to zero.
10991115
11001116
:seealso: :func:`Robot.friction`, :func:`Link.nofriction`
11011117
"""

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy