def _import(self, value, check=True): if isinstance(value, np.ndarray) and self.isvalid(value, check=check): if value.shape == (3, 3): # it's an se(2) return base.vexa(value) elif value.shape == (3, ): # it's a twist vector return value elif base.ishom2(value, check=check): return base.trlog2(value, twist=True, check=False) raise TypeError('bad type passed')
def isvalid(x, check=True): """ Test if matrix is valid SE(2) :param x: matrix to test :type x: numpy.ndarray :return: true if the matrix is a valid element of SE(2), ie. it is a 3x3 homogeneous rigid-body transformation matrix. :rtype: bool :seealso: :func:`~spatialmath.base.transform2d.ishom` """ return not check or tr.ishom2(x, check=True)
def isvalid(x): return tr.ishom2(x, check=True)