12
12
13
13
14
14
class BaseELink (Link ):
15
-
16
15
def __init__ (self , name = None , parent = None , joint_name = None , ** kwargs ):
17
16
18
17
super ().__init__ (** kwargs )
@@ -23,7 +22,7 @@ def __init__(self, name=None, parent=None, joint_name=None, **kwargs):
23
22
if isinstance (parent , (str , BaseELink )):
24
23
self ._parent = parent
25
24
else :
26
- raise TypeError (' parent must be BaseELink subclass or str' )
25
+ raise TypeError (" parent must be BaseELink subclass or str" )
27
26
else :
28
27
self ._parent = None
29
28
@@ -292,11 +291,11 @@ def collision(self, coll):
292
291
if isinstance (gi , Shape ):
293
292
new_coll .append (gi )
294
293
else :
295
- raise TypeError (' Collision must be of Shape class' )
294
+ raise TypeError (" Collision must be of Shape class" )
296
295
elif isinstance (coll , Shape ):
297
296
new_coll .append (coll )
298
297
else :
299
- raise TypeError (' Geometry must be of Shape class or list of Shape' )
298
+ raise TypeError (" Geometry must be of Shape class or list of Shape" )
300
299
301
300
self ._collision = new_coll
302
301
@@ -309,11 +308,11 @@ def geometry(self, geom):
309
308
if isinstance (gi , Shape ):
310
309
new_geom .append (gi )
311
310
else :
312
- raise TypeError (' Geometry must be of Shape class' )
311
+ raise TypeError (" Geometry must be of Shape class" )
313
312
elif isinstance (geom , Shape ):
314
313
new_geom .append (geom )
315
314
else :
316
- raise TypeError (' Geometry must be of Shape class or list of Shape' )
315
+ raise TypeError (" Geometry must be of Shape class or list of Shape" )
317
316
318
317
self ._geometry = new_geom
319
318
@@ -355,20 +354,14 @@ class ELink(BaseELink):
355
354
:seealso: :class:`Link`, :class:`DHLink`
356
355
"""
357
356
358
- def __init__ (
359
- self ,
360
- ets = ETS (),
361
- v = None ,
362
- jindex = None ,
363
- ** kwargs ):
357
+ def __init__ (self , ets = ETS (), v = None , jindex = None , ** kwargs ):
364
358
365
359
# process common options
366
360
super ().__init__ (** kwargs )
367
361
368
362
# check we have an ETS
369
363
if not isinstance (ets , ETS ):
370
- raise TypeError (
371
- 'The ets argument must be of type ETS' )
364
+ raise TypeError ("The ets argument must be of type ETS" )
372
365
373
366
self ._ets = ets
374
367
@@ -388,12 +381,11 @@ def __init__(
388
381
if v is None :
389
382
self ._joint = False
390
383
elif not isinstance (v , ETS ):
391
- raise TypeError (' v must be of type ETS' )
384
+ raise TypeError (" v must be of type ETS" )
392
385
elif not v [0 ].isjoint :
393
- raise ValueError (' v must be a variable ETS' )
386
+ raise ValueError (" v must be a variable ETS" )
394
387
elif len (v ) > 1 :
395
- raise ValueError (
396
- "An elementary link can only have one joint variable" )
388
+ raise ValueError ("An elementary link can only have one joint variable" )
397
389
else :
398
390
self ._joint = True
399
391
@@ -418,17 +410,17 @@ def _get_fknm(self):
418
410
if jindex is None :
419
411
jindex = 0
420
412
421
- if self ._v .axis == 'Rx' :
413
+ if self ._v .axis == "Rx" :
422
414
axis = 0
423
- elif self ._v .axis == 'Ry' :
415
+ elif self ._v .axis == "Ry" :
424
416
axis = 1
425
- elif self ._v .axis == 'Rz' :
417
+ elif self ._v .axis == "Rz" :
426
418
axis = 2
427
- elif self ._v .axis == 'tx' :
419
+ elif self ._v .axis == "tx" :
428
420
axis = 3
429
- elif self ._v .axis == 'ty' :
421
+ elif self ._v .axis == "ty" :
430
422
axis = 4
431
- elif self ._v .axis == 'tz' :
423
+ elif self ._v .axis == "tz" :
432
424
axis = 5
433
425
434
426
if self .parent is None :
@@ -453,22 +445,38 @@ def _get_fknm(self):
453
445
shape_sT .append (shap ._sT )
454
446
shape_sq .append (shap ._sq )
455
447
456
- return isflip , axis , jindex , parent , shape_base , shape_wT , \
457
- shape_sT , shape_sq
448
+ return isflip , axis , jindex , parent , shape_base , shape_wT , shape_sT , shape_sq
458
449
459
450
def _init_fknm (self ):
460
451
if isinstance (self .parent , str ):
461
452
# Initialise later
462
453
return
463
454
464
- isflip , axis , jindex , parent , \
465
- shape_base , shape_wT , shape_sT , shape_sq = self ._get_fknm ()
455
+ (
456
+ isflip ,
457
+ axis ,
458
+ jindex ,
459
+ parent ,
460
+ shape_base ,
461
+ shape_wT ,
462
+ shape_sT ,
463
+ shape_sq ,
464
+ ) = self ._get_fknm ()
466
465
467
466
self ._fknm = fknm .link_init (
468
- self .isjoint , isflip , axis , jindex , len (shape_base ),
469
- self ._Ts , self ._fk ,
470
- shape_base , shape_wT , shape_sT , shape_sq ,
471
- parent )
467
+ self .isjoint ,
468
+ isflip ,
469
+ axis ,
470
+ jindex ,
471
+ len (shape_base ),
472
+ self ._Ts ,
473
+ self ._fk ,
474
+ shape_base ,
475
+ shape_wT ,
476
+ shape_sT ,
477
+ shape_sq ,
478
+ parent ,
479
+ )
472
480
473
481
def _update_fknm (self ):
474
482
@@ -480,15 +488,32 @@ def _update_fknm(self):
480
488
except AttributeError :
481
489
return
482
490
483
- isflip , axis , jindex , parent , \
484
- shape_base , shape_wT , shape_sT , shape_sq = self ._get_fknm ()
491
+ (
492
+ isflip ,
493
+ axis ,
494
+ jindex ,
495
+ parent ,
496
+ shape_base ,
497
+ shape_wT ,
498
+ shape_sT ,
499
+ shape_sq ,
500
+ ) = self ._get_fknm ()
485
501
486
502
fknm .link_update (
487
503
self ._fknm ,
488
- self .isjoint , isflip , axis , jindex , len (shape_base ),
489
- self ._Ts , self ._fk ,
490
- shape_base , shape_wT , shape_sT , shape_sq ,
491
- parent )
504
+ self .isjoint ,
505
+ isflip ,
506
+ axis ,
507
+ jindex ,
508
+ len (shape_base ),
509
+ self ._Ts ,
510
+ self ._fk ,
511
+ shape_base ,
512
+ shape_wT ,
513
+ shape_sT ,
514
+ shape_sq ,
515
+ parent ,
516
+ )
492
517
493
518
def _init_Ts (self ):
494
519
# Number of transforms in the ETS excluding the joint variable
@@ -508,7 +533,7 @@ def _init_Ts(self):
508
533
for et in self ._ets :
509
534
# constant transforms only
510
535
if et .isjoint :
511
- raise ValueError (' The transforms in ets must be constant' )
536
+ raise ValueError (" The transforms in ets must be constant" )
512
537
513
538
# if first:
514
539
# T = et.T()
@@ -522,7 +547,7 @@ def _init_Ts(self):
522
547
523
548
elif isinstance (self ._ets , SE3 ):
524
549
self ._Ts = self ._ets
525
- raise RuntimeError (' this shouldnt happen' )
550
+ raise RuntimeError (" this shouldnt happen" )
526
551
527
552
@property
528
553
def geometry (self ):
@@ -562,11 +587,11 @@ def collision(self, coll):
562
587
if isinstance (gi , Shape ):
563
588
new_coll .append (gi )
564
589
else :
565
- raise TypeError (' Collision must be of Shape class' )
590
+ raise TypeError (" Collision must be of Shape class" )
566
591
elif isinstance (coll , Shape ):
567
592
new_coll .append (coll )
568
593
else :
569
- raise TypeError (' Geometry must be of Shape class or list of Shape' )
594
+ raise TypeError (" Geometry must be of Shape class or list of Shape" )
570
595
571
596
self ._collision = new_coll
572
597
self ._update_fknm ()
@@ -581,11 +606,11 @@ def geometry(self, geom):
581
606
if isinstance (gi , Shape ):
582
607
new_geom .append (gi )
583
608
else :
584
- raise TypeError (' Geometry must be of Shape class' )
609
+ raise TypeError (" Geometry must be of Shape class" )
585
610
elif isinstance (geom , Shape ):
586
611
new_geom .append (geom )
587
612
else :
588
- raise TypeError (' Geometry must be of Shape class or list of Shape' )
613
+ raise TypeError (" Geometry must be of Shape class or list of Shape" )
589
614
590
615
self ._geometry = new_geom
591
616
self ._update_fknm ()
@@ -652,21 +677,14 @@ def A(self, q=0.0, fast=False):
652
677
653
678
654
679
class ELink2 (BaseELink ):
655
-
656
- def __init__ (
657
- self ,
658
- ets = ETS2 (),
659
- v = None ,
660
- jindex = None ,
661
- ** kwargs ):
680
+ def __init__ (self , ets = ETS2 (), v = None , jindex = None , ** kwargs ):
662
681
663
682
# process common options
664
683
super ().__init__ (** kwargs )
665
684
666
685
# check we have an ETS
667
686
if not isinstance (ets , ETS2 ):
668
- raise TypeError (
669
- 'The ets argument must be of type ETS2' )
687
+ raise TypeError ("The ets argument must be of type ETS2" )
670
688
671
689
self ._ets = ets
672
690
@@ -685,12 +703,11 @@ def __init__(
685
703
if v is None :
686
704
self ._joint = False
687
705
elif not isinstance (v , ETS2 ):
688
- raise TypeError (' v must be of type ETS2' )
706
+ raise TypeError (" v must be of type ETS2" )
689
707
elif not v [0 ].isjoint :
690
- raise ValueError (' v must be a variable ETS' )
708
+ raise ValueError (" v must be a variable ETS" )
691
709
elif len (v ) > 1 :
692
- raise ValueError (
693
- "An elementary link can only have one joint variable" )
710
+ raise ValueError ("An elementary link can only have one joint variable" )
694
711
else :
695
712
self ._joint = True
696
713
@@ -711,15 +728,15 @@ def _init_Ts(self):
711
728
for et in self ._ets :
712
729
# constant transforms only
713
730
if et .isjoint :
714
- raise ValueError (' The transforms in ets must be constant' )
731
+ raise ValueError (" The transforms in ets must be constant" )
715
732
716
733
T = T @ et .T ()
717
734
718
735
self ._Ts = T
719
736
720
737
elif isinstance (self ._ets , SE3 ):
721
738
self ._Ts = self ._ets
722
- raise RuntimeError (' this shouldnt happen' )
739
+ raise RuntimeError (" this shouldnt happen" )
723
740
724
741
def A (self , q = 0.0 , ** kwargs ):
725
742
"""
0 commit comments