Skip to content

Commit 19fda53

Browse files
committed
change arg from mtype to type
use inspect module now to determine if reference is a class
1 parent c7ff798 commit 19fda53

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

roboticstoolbox/models/list.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,26 @@
33
from roboticstoolbox.tools import rtb_get_param
44
from roboticstoolbox.robot.ERobot import ERobot2
55
from ansitable import ANSITable, Column
6+
import inspect
67

78
# import importlib
89

910

10-
def list(keywords=None, dof=None, mtype=None, border=None):
11+
def list(keywords=None, dof=None, type=None, border="thin"):
1112
"""
1213
Display all robot models in summary form
1314
1415
:param keywords: keywords to filter on, defaults to None
1516
:type keywords: tuple of str, optional
1617
:param dof: number of DoF to filter on, defaults to None
1718
:type dof: int, optional
19+
:param type: model type "DH", "ETS", "URDF", defaults to all types
20+
:type type: str, optional
1821
1922
- ``list()`` displays a list of all models provided by the Toolbox. It
2023
lists the name, manufacturer, model type, number of DoF, and keywords.
2124
22-
- ``list(mtype=MT)`` as above, but only displays models of type ``MT``
25+
- ``list(type=MT)`` as above, but only displays models of type ``MT``
2326
where ``MT`` is one of "DH", "ETS" or "URDF".
2427
2528
- ``list(keywords=KW)`` as above, but only displays models that have a
@@ -34,7 +37,7 @@ def list(keywords=None, dof=None, mtype=None, border=None):
3437
``KW`` and have ``N`` degrees of freedom.
3538
"""
3639

37-
import roboticstoolbox.models as m
40+
import roboticstoolbox.models as models
3841

3942
# module = importlib.import_module(
4043
# '.' + os.path.splitext(file)[0], package='bdsim.blocks')
@@ -57,14 +60,15 @@ def make_table(border=None):
5760
border=border,
5861
)
5962

60-
if mtype is not None:
61-
categories = [mtype]
63+
if type is not None:
64+
categories = [type]
6265
else:
6366
categories = ["DH", "URDF", "ETS"]
6467
for category in categories:
65-
group = m.__dict__[category]
68+
# get all classes in this category
69+
group = models.__dict__[category]
6670
for cls in group.__dict__.values():
67-
if isinstance(cls, type) and issubclass(cls, Robot):
71+
if inspect.isclass(cls) and issubclass(cls, Robot):
6872
# we found a BaseRobot subclass, instantiate it
6973
try:
7074
robot = cls()

0 commit comments

Comments
 (0)