1818import math
1919import numpy as np
2020import scipy .linalg
21- from spatialmath import base
21+ import spatialmath . base as smb
2222
2323_eps = np .finfo (np .float64 ).eps
2424
@@ -52,9 +52,9 @@ def rot2(theta, unit="rad"):
5252 >>> rot2(0.3)
5353 >>> rot2(45, 'deg')
5454 """
55- theta = base .getunit (theta , unit )
56- ct = base .sym .cos (theta )
57- st = base .sym .sin (theta )
55+ theta = smb .getunit (theta , unit )
56+ ct = smb .sym .cos (theta )
57+ st = smb .sym .sin (theta )
5858 # fmt: off
5959 R = np .array ([
6060 [ct , - st ],
@@ -94,7 +94,7 @@ def trot2(theta, unit="rad", t=None):
9494 """
9595 T = np .pad (rot2 (theta , unit ), (0 , 1 ), mode = "constant" )
9696 if t is not None :
97- T [:2 , 2 ] = base .getvector (t , 2 , "array" )
97+ T [:2 , 2 ] = smb .getvector (t , 2 , "array" )
9898 T [2 , 2 ] = 1 # integer to be symbolic friendly
9999 return T
100100
@@ -121,7 +121,7 @@ def xyt2tr(xyt, unit="rad"):
121121
122122 :seealso: tr2xyt
123123 """
124- xyt = base .getvector (xyt , 3 )
124+ xyt = smb .getvector (xyt , 3 )
125125 T = np .pad (rot2 (xyt [2 ], unit ), (0 , 1 ), mode = "constant" )
126126 T [:2 , 2 ] = xyt [0 :2 ]
127127 T [2 , 2 ] = 1.0
@@ -211,13 +211,13 @@ def transl2(x, y=None):
211211 function.
212212 """
213213
214- if base .isscalar (x ) and base .isscalar (y ):
214+ if smb .isscalar (x ) and smb .isscalar (y ):
215215 # (x, y) -> SE(2)
216216 t = np .r_ [x , y ]
217- elif base .isvector (x , 2 ):
217+ elif smb .isvector (x , 2 ):
218218 # R2 -> SE(2)
219- t = base .getvector (x , 2 )
220- elif base .ismatrix (x , (3 , 3 )):
219+ t = smb .getvector (x , 2 )
220+ elif smb .ismatrix (x , (3 , 3 )):
221221 # SE(2) -> R2
222222 return x [:2 , 2 ]
223223 else :
@@ -264,7 +264,7 @@ def ishom2(T, check=False):
264264 and T .shape == (3 , 3 )
265265 and (
266266 not check
267- or (base .isR (T [:2 , :2 ]) and np .all (T [2 , :] == np .array ([0 , 0 , 1 ])))
267+ or (smb .isR (T [:2 , :2 ]) and np .all (T [2 , :] == np .array ([0 , 0 , 1 ])))
268268 )
269269 )
270270
@@ -298,7 +298,7 @@ def isrot2(R, check=False):
298298 :seealso: isR, ishom2, isrot
299299 """
300300 return (
301- isinstance (R , np .ndarray ) and R .shape == (2 , 2 ) and (not check or base .isR (R ))
301+ isinstance (R , np .ndarray ) and R .shape == (2 , 2 ) and (not check or smb .isR (R ))
302302 )
303303
304304
@@ -466,55 +466,55 @@ def trexp2(S, theta=None, check=True):
466466 :seealso: trlog, trexp2
467467 """
468468
469- if base .ismatrix (S , (3 , 3 )) or base .isvector (S , 3 ):
469+ if smb .ismatrix (S , (3 , 3 )) or smb .isvector (S , 3 ):
470470 # se(2) case
471- if base .ismatrix (S , (3 , 3 )):
471+ if smb .ismatrix (S , (3 , 3 )):
472472 # augmentented skew matrix
473- if check and not base .isskewa (S ):
473+ if check and not smb .isskewa (S ):
474474 raise ValueError ("argument must be a valid se(2) element" )
475- tw = base .vexa (S )
475+ tw = smb .vexa (S )
476476 else :
477477 # 3 vector
478- tw = base .getvector (S )
478+ tw = smb .getvector (S )
479479
480- if base .iszerovec (tw ):
480+ if smb .iszerovec (tw ):
481481 return np .eye (3 )
482482
483483 if theta is None :
484- (tw , theta ) = base .unittwist2_norm (tw )
485- elif not base .isunittwist2 (tw ):
484+ (tw , theta ) = smb .unittwist2_norm (tw )
485+ elif not smb .isunittwist2 (tw ):
486486 raise ValueError ("If theta is specified S must be a unit twist" )
487487
488488 t = tw [0 :2 ]
489489 w = tw [2 ]
490490
491- R = base .rodrigues (w , theta )
491+ R = smb .rodrigues (w , theta )
492492
493- skw = base .skew (w )
493+ skw = smb .skew (w )
494494 V = (
495495 np .eye (2 ) * theta
496496 + (1.0 - math .cos (theta )) * skw
497497 + (theta - math .sin (theta )) * skw @ skw
498498 )
499499
500- return base .rt2tr (R , V @ t )
500+ return smb .rt2tr (R , V @ t )
501501
502- elif base .ismatrix (S , (2 , 2 )) or base .isvector (S , 1 ):
502+ elif smb .ismatrix (S , (2 , 2 )) or smb .isvector (S , 1 ):
503503 # so(2) case
504- if base .ismatrix (S , (2 , 2 )):
504+ if smb .ismatrix (S , (2 , 2 )):
505505 # skew symmetric matrix
506- if check and not base .isskew (S ):
506+ if check and not smb .isskew (S ):
507507 raise ValueError ("argument must be a valid so(2) element" )
508- w = base .vex (S )
508+ w = smb .vex (S )
509509 else :
510510 # 1 vector
511- w = base .getvector (S )
511+ w = smb .getvector (S )
512512
513- if theta is not None and not base .isunitvec (w ):
513+ if theta is not None and not smb .isunitvec (w ):
514514 raise ValueError ("If theta is specified S must be a unit twist" )
515515
516516 # do Rodrigues' formula for rotation
517- return base .rodrigues (w , theta )
517+ return smb .rodrigues (w , theta )
518518 else :
519519 raise ValueError (" First argument must be SO(2), 1-vector, SE(2) or 3-vector" )
520520
@@ -526,7 +526,7 @@ def adjoint2(T):
526526 return np .identity (2 )
527527 elif T .shape == (3 , 3 ):
528528 # SE(2) adjoint
529- (R , t ) = base .tr2rt (T )
529+ (R , t ) = smb .tr2rt (T )
530530 # fmt: off
531531 return np .block ([
532532 [R , np .c_ [t [1 ], - t [0 ]].T ],
@@ -567,7 +567,7 @@ def tr2jac2(T):
567567 raise ValueError ("expecting an SE(2) matrix" )
568568
569569 J = np .eye (3 , dtype = T .dtype )
570- J [:2 , :2 ] = base .t2r (T )
570+ J [:2 , :2 ] = smb .t2r (T )
571571 return J
572572
573573
@@ -608,10 +608,10 @@ def trinterp2(start, end, s=None):
608608 >>> trinterp2(None, T2, 1)
609609 >>> trinterp2(None, T2, 0.5)
610610
611- :seealso: :func:`~spatialmath.base .transforms3d.trinterp`
611+ :seealso: :func:`~spatialmath.smb .transforms3d.trinterp`
612612
613613 """
614- if base .ismatrix (end , (2 , 2 )):
614+ if smb .ismatrix (end , (2 , 2 )):
615615 # SO(2) case
616616 if start is None :
617617 # TRINTERP2(T, s)
@@ -630,7 +630,7 @@ def trinterp2(start, end, s=None):
630630 th = th0 * (1 - s ) + s * th1
631631
632632 return rot2 (th )
633- elif base .ismatrix (end , (3 , 3 )):
633+ elif smb .ismatrix (end , (3 , 3 )):
634634 if start is None :
635635 # TRINTERP2(T, s)
636636
@@ -653,7 +653,7 @@ def trinterp2(start, end, s=None):
653653 pr = p0 * (1 - s ) + s * p1
654654 th = th0 * (1 - s ) + s * th1
655655
656- return base .rt2tr (rot2 (th ), pr )
656+ return smb .rt2tr (rot2 (th ), pr )
657657 else :
658658 return ValueError ("Argument must be SO(2) or SE(2)" )
659659
@@ -930,7 +930,7 @@ def _AlignSVD(source, reference):
930930 # translation is the difference between the point clound centroids
931931 t = ref_centroid - R @ src_centroid
932932
933- return base .rt2tr (R , t )
933+ return smb .rt2tr (R , t )
934934
935935def trplot2 (
936936 T ,
@@ -1035,11 +1035,11 @@ def trplot2(
10351035
10361036 # check input types
10371037 if isrot2 (T , check = True ):
1038- T = base .r2t (T )
1038+ T = smb .r2t (T )
10391039 elif not ishom2 (T , check = True ):
10401040 raise ValueError ("argument is not valid SE(2) matrix" )
10411041
1042- ax = base .axes_logic (ax , 2 )
1042+ ax = smb .axes_logic (ax , 2 )
10431043
10441044 try :
10451045 if not ax .get_xlabel ():
@@ -1053,7 +1053,7 @@ def trplot2(
10531053 ax .set_aspect ("equal" )
10541054
10551055 if dims is not None :
1056- ax .axis (base .expand_dims (dims ))
1056+ ax .axis (smb .expand_dims (dims ))
10571057 elif not hasattr (ax , "_plotvol" ):
10581058 ax .autoscale (enable = True , axis = "both" )
10591059
@@ -1172,7 +1172,7 @@ def tranimate2(T, **kwargs):
11721172 tranimate2(transl(1,2)@trot2(1), frame='A', arrow=False, dims=[0, 5])
11731173 tranimate2(transl(1,2)@trot2(1), frame='A', arrow=False, dims=[0, 5], movie='spin.mp4')
11741174 """
1175- anim = base .animate .Animate2 (** kwargs )
1175+ anim = smb .animate .Animate2 (** kwargs )
11761176 try :
11771177 del kwargs ["dims" ]
11781178 except KeyError :
0 commit comments