Skip to content

Commit d9212bb

Browse files
committed
simplify constructor from SE3
1 parent 1b05196 commit d9212bb

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎spatialmath/twist.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,15 +341,18 @@ def __init__(self, arg=None, w=None, check=True):
341341

342342
if w is None:
343343
# zero or one arguments passed
344-
if super().arghandler(arg, convertfrom=(SE3,), check=check):
344+
if super().arghandler(arg, check=check):
345345
return
346+
elif isinstance(arg, SE3):
347+
self.data = [arg.twist().A]
346348

347349
elif w is not None and base.isvector(w, 3) and base.isvector(arg,3):
348350
# Twist(v, w)
349351
self.data = [np.r_[arg, w]]
350352
return
351353

352-
raise ValueError('bad twist value')
354+
else:
355+
raise ValueError('bad value to Twist constructor')
353356

354357
# ------------------------ SMUserList required ---------------------------#
355358

@@ -1564,8 +1567,8 @@ def _repr_pretty_(self, p, cycle):
15641567

15651568
if __name__ == '__main__': # pragma: no cover
15661569

1570+
tw = Twist3( SE3.Rx(0) )
15671571

1572+
# import pathlib
15681573

1569-
import pathlib
1570-
1571-
exec(open(pathlib.Path(__file__).parent.parent.absolute() / "tests" / "test_twist.py").read()) # pylint: disable=exec-used
1574+
# exec(open(pathlib.Path(__file__).parent.parent.absolute() / "tests" / "test_twist.py").read()) # pylint: disable=exec-used

0 commit comments

Comments
 (0)