@@ -75,6 +75,8 @@ def __init__(
75
75
76
76
self ._hasdynamics = False
77
77
self ._hasgeometry = False
78
+ self ._hascollision = False
79
+
78
80
79
81
for link in links :
80
82
if not isinstance (link , Link ):
@@ -83,13 +85,18 @@ def __init__(
83
85
# add link back to roboto
84
86
link ._robot = self
85
87
86
- if link ._hasdynamics :
88
+ if link .hasdynamics :
87
89
self ._hasdynamics = True
90
+ if link .geometry :
91
+ self ._hasgeometry = []
92
+ if link .collision :
93
+ self ._hascollision = True
88
94
89
95
if isinstance (link , rtb .ELink ):
90
96
if len (link .geometry ) > 0 :
91
97
self ._hasgeometry = True
92
98
self ._links = links
99
+ self ._nlinks = len (links )
93
100
94
101
# Current joint angles of the robot
95
102
self .q = np .zeros (self .n )
@@ -217,9 +224,117 @@ def n(self):
217
224
>>> robot = rtb.models.DH.Puma560()
218
225
>>> robot.n
219
226
227
+ :seealso: :func:`nlinks`, :func:`nbranches`
228
+ """
229
+ return self ._n
230
+
231
+ @property
232
+ def nlinks (self ):
233
+ """
234
+ Number of links (Robot superclass)
235
+
236
+ :return: Number of links
237
+ :rtype: int
238
+
239
+ Example:
240
+
241
+ .. runblock:: pycon
242
+
243
+ >>> import roboticstoolbox as rtb
244
+ >>> robot = rtb.models.DH.Puma560()
245
+ >>> robot.nlinks
246
+
247
+ :seealso: :func:`n`, :func:`nbranches`
248
+ """
249
+ return self ._nlinks
250
+
251
+ @abstractproperty
252
+ def nbranches (self ):
253
+ pass
254
+
255
+ """
256
+ Number of branches (Robot superclass)
257
+
258
+ :return: Number of branches
259
+ :rtype: int
260
+
261
+ Example:
262
+
263
+ .. runblock:: pycon
264
+
265
+ >>> import roboticstoolbox as rtb
266
+ >>> robot = rtb.models.DH.Puma560()
267
+ >>> robot.nbranches
268
+
269
+ :seealso: :func:`n`, :func:`nlinks`
220
270
"""
221
271
return self ._n
222
272
273
+ @property
274
+ def hasdynamics (self ):
275
+ """
276
+ Robot has dynamic parameters (Robot superclass)
277
+
278
+ :return: Robot has dynamic parameters
279
+ :rtype: bool
280
+
281
+ At least one link has associated dynamic parameters.
282
+
283
+ Example:
284
+
285
+ .. runblock:: pycon
286
+
287
+ >>> import roboticstoolbox as rtb
288
+ >>> robot = rtb.models.DH.Puma560()
289
+ >>> robot.hasdynamics:
290
+ """
291
+ return self ._hasdynamics
292
+
293
+ @property
294
+ def hasgeometry (self ):
295
+ """
296
+ Robot has geometry model (Robot superclass)
297
+
298
+ :return: Robot has geometry model
299
+ :rtype: bool
300
+
301
+ At least one link has associated mesh to describe its shape.
302
+
303
+ Example:
304
+
305
+ .. runblock:: pycon
306
+
307
+ >>> import roboticstoolbox as rtb
308
+ >>> robot = rtb.models.DH.Puma560()
309
+ >>> robot.hasgeometry
310
+
311
+ :seealso: :func:`hascollision`
312
+ """
313
+ return self ._hasgeometry
314
+
315
+ @property
316
+ def hascollision (self ):
317
+ """
318
+ Robot has collision model (Robot superclass)
319
+
320
+ :return: Robot has collision model
321
+ :rtype: bool
322
+
323
+ At least one link has associated collision model.
324
+
325
+ Example:
326
+
327
+ .. runblock:: pycon
328
+
329
+ >>> import roboticstoolbox as rtb
330
+ >>> robot = rtb.models.DH.Puma560()
331
+ >>> robot.hascollision
332
+
333
+ :seealso: :func:`hasgeometry`
334
+ """
335
+ return self ._hascollision
336
+
337
+
223
338
@property
224
339
def qrandom (self ):
225
340
"""
@@ -330,7 +445,8 @@ def structure(self):
330
445
331
446
return '' .join (structure )
332
447
333
- def isrevolute (self ):
448
+ @property
449
+ def revolutejoints (self ):
334
450
"""
335
451
Revolute joints as bool array
336
452
@@ -343,16 +459,27 @@ def isrevolute(self):
343
459
344
460
>>> import roboticstoolbox as rtb
345
461
>>> puma = rtb.models.DH.Puma560()
346
- >>> puma.isrevolute ()
462
+ >>> puma.revolutejoints ()
347
463
>>> stanford = rtb.models.DH.Stanford()
348
- >>> stanford.isrevolute ()
464
+ >>> stanford.revolutejoints ()
349
465
350
466
.. note:: Fixed joints, that maintain a constant link relative pose,
351
467
are not included. ``len(self.structure) == self.n``.
468
+
469
+ :seealso: :func:`Link.isrevolute`, :func:`prismaticjoints`
352
470
"""
353
- return [link .isrevolute for link in self ]
471
+ return [link .isrevolute for link in self if link .isjoint ]
472
+
473
+ # TODO not very efficient
474
+ # TODO keep a mapping from joint to link
475
+ def isrevolute (self , j ):
476
+ return self .revolutejoints [j ]
354
477
355
- def isprismatic (self ):
478
+ def isprismatic (self , j ):
479
+ return self .prismaticjoints [j ]
480
+
481
+ @property
482
+ def prismaticjoints (self ):
356
483
"""
357
484
Revolute joints as bool array
358
485
0 commit comments