@@ -169,7 +169,7 @@ def trlog2(T, check=True, twist=False):
169
169
:type twist: bool
170
170
:return: logarithm
171
171
:rtype: numpy.ndarray, shape=(2,2) or (3,3)
172
- :raises: ValueError
172
+ :raises ValueError: bad argument
173
173
174
174
An efficient closed-form solution of the matrix logarithm for arguments that
175
175
are SO(2) or SE(2).
@@ -223,6 +223,7 @@ def trexp2(S, theta=None, check=True):
223
223
:type theta: float
224
224
:return: 2x2 or 3x3 matrix exponential in SO(2) or SE(2)
225
225
:rtype: numpy.ndarray, shape=(2,2) or (3,3)
226
+ :raises ValueError: bad argument
226
227
227
228
An efficient closed-form solution of the matrix exponential for arguments
228
229
that are so(2) or se(2).
@@ -261,8 +262,8 @@ def trexp2(S, theta=None, check=True):
261
262
# se(2) case
262
263
if base .ismatrix (S , (3 , 3 )):
263
264
# augmentented skew matrix
264
- if check :
265
- assert base . isskewa ( S ), ' argument must be a valid se(2) element'
265
+ if check and not base . isskewa ( S ) :
266
+ raise ValueError ( " argument must be a valid se(2) element" )
266
267
tw = base .vexa (S )
267
268
else :
268
269
# 3 vector
@@ -273,8 +274,8 @@ def trexp2(S, theta=None, check=True):
273
274
274
275
if theta is None :
275
276
(tw , theta ) = base .unittwist2_norm (tw )
276
- else :
277
- assert base . isunittwist2 ( tw ), ' If theta is specified S must be a unit twist'
277
+ elif not base . isunittwist2 ( tw ) :
278
+ raise ValueError ( " If theta is specified S must be a unit twist" )
278
279
279
280
t = tw [0 :2 ]
280
281
w = tw [2 ]
@@ -290,15 +291,15 @@ def trexp2(S, theta=None, check=True):
290
291
# so(2) case
291
292
if base .ismatrix (S , (2 , 2 )):
292
293
# skew symmetric matrix
293
- if check :
294
- assert base . isskew ( S ), ' argument must be a valid so(2) element'
294
+ if check and not base . isskew ( S ) :
295
+ raise ValueError ( " argument must be a valid so(2) element" )
295
296
w = base .vex (S )
296
297
else :
297
298
# 1 vector
298
299
w = base .getvector (S )
299
300
300
- if theta is not None :
301
- assert base . isunitvec ( w ), ' If theta is specified S must be a unit twist'
301
+ if theta is not None and not base . isunitvec ( w ) :
302
+ raise ValueError ( " If theta is specified S must be a unit twist" )
302
303
303
304
# do Rodrigues' formula for rotation
304
305
return base .rodrigues (w , theta )
@@ -318,6 +319,7 @@ def trinterp2(start, end, s=None):
318
319
:type s: float
319
320
:return: SO(2) or SE(2) matrix
320
321
:rtype: np.ndarray, shape=(2,2), (3,3)
322
+ :raises ValueError: bad arguments
321
323
322
324
- ``trinterp2(None, T, S)`` is a homogeneous transform (3x3) interpolated
323
325
between identity when S=0 and T (3x3) when S=1.
@@ -346,7 +348,8 @@ def trinterp2(start, end, s=None):
346
348
th = s * th0
347
349
else :
348
350
# TRINTERP2(T1, start= s)
349
- assert start .shape == end .shape , 'start and end matrices must be same shape'
351
+ if start .shape != end .shape :
352
+ raise ValueError ("start and end matrices must be same shape" )
350
353
351
354
th0 = math .atan2 (start [1 , 0 ], start [0 , 0 ])
352
355
th1 = math .atan2 (end [1 , 0 ], end [0 , 0 ])
@@ -365,7 +368,8 @@ def trinterp2(start, end, s=None):
365
368
pr = s * p0
366
369
else :
367
370
# TRINTERP2(T0, T1, s)
368
- assert start .shape == end .shape , 'both matrices must be same shape'
371
+ if start .shape != end .shape :
372
+ raise ValueError ("both matrices must be same shape" )
369
373
370
374
th0 = math .atan2 (start [1 , 0 ], start [0 , 0 ])
371
375
th1 = math .atan2 (end [1 , 0 ], end [0 , 0 ])
@@ -493,6 +497,7 @@ def trplot2(T, axes=None, block=True, dims=None, color='blue', frame=None, # pyl
493
497
:type d2: distance of frame label text from origin, default 0.05
494
498
:return: axes containing the frame
495
499
:rtype: AxesSubplot
500
+ :raises ValueError: bad argument
496
501
497
502
Adds a 2D coordinate frame represented by the SO(2) or SE(2) matrix to the current axes.
498
503
@@ -514,8 +519,8 @@ def trplot2(T, axes=None, block=True, dims=None, color='blue', frame=None, # pyl
514
519
# check input types
515
520
if isrot2 (T , check = True ):
516
521
T = base .r2t (T )
517
- else :
518
- assert ishom2 ( T , check = True )
522
+ elif not ishom2 ( T , check = True ) :
523
+ raise ValueError ( "argument is not valid SE(2) matrix" )
519
524
520
525
if axes is None :
521
526
# create an axes
0 commit comments