Skip to content

Commit 9b8296a

Browse files
committed
allow matrix argument to be given to constructor as list of lists, no need to create ndarray first.
1 parent d7a8c7b commit 9b8296a

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

spatialmath/baseposelist.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,13 @@ def arghandler(
212212
self.data = [np.array(arg)]
213213

214214
else:
215-
return False
215+
# see what NumPy makes of it
216+
X = np.array(arg)
217+
if X.shape == self.shape:
218+
self.data = [X]
219+
else:
220+
# no idea what was passed
221+
return False
216222

217223
elif isinstance(arg, self.__class__):
218224
# instance of same type, clone it
@@ -660,3 +666,12 @@ def unop(
660666
return np.vstack([op(x) for x in self.data])
661667
else:
662668
return [op(x) for x in self.data]
669+
670+
if __name__ == "__main__":
671+
from spatialmath import SO3, SO2
672+
673+
R = SO3([[1,0,0],[0,1,0],[0,0,1]])
674+
print(R.eulervec())
675+
676+
R = SO2([0.3, 0.4, 0.5])
677+
pass

0 commit comments

Comments
 (0)