def trplot(self, end, start=None, **kwargs): """ Define the transform to animate :param end: the final pose SO(3) or SE(3) to display as a coordinate frame :type end: numpy.ndarray, shape=(3,3) or (4,4) :param start: the initial pose SO(3) or SE(3) to display as a coordinate frame, defaults to null :type start: numpy.ndarray, shape=(3,3) or (4,4) :param start: an Is polymorphic with ``base.trplot`` and accepts the same parameters. This sets up the animation but doesn't execute it. :seealso: :func:`run` """ # stash the final value if tr.isrot(end): self.end = tr.r2t(end) else: self.end = end if start is None: self.start = np.identity(4) else: if tr.isrot(start): self.start = tr.r2t(start) else: self.start = start # draw axes at the origin tr.trplot(self.start, axes=self, block=None, **kwargs)
def trplot(self, end, start=None, **kwargs): """ Define the transform to animate :param end: the final pose SE(3) or SO(3) to display as a coordinate frame :type end: ndarray(4,4) or ndarray(3,3) :param start: the initial pose SE(3) or SO(3) to display as a coordinate frame, defaults to null :type start: ndarray(4,4) or ndarray(3,3) :param start: an Is polymorphic with ``base.trplot`` and accepts the same parameters. This sets up the animation but doesn't execute it. :seealso: :func:`run` """ if not isinstance(end, (np.ndarray, np.generic)) and isinstance( end, Iterable): try: if len(end) == 1: end = end[0] elif len(end) >= 2: self.trajectory = end except TypeError: # a generator has no len() self.trajectory = end # stash the final value if base.isrot(end): self.end = base.r2t(end) else: self.end = end if start is None: self.start = np.identity(4) else: if base.isrot(start): self.start = base.r2t(start) else: self.start = start # draw axes at the origin base.trplot(self.start, axes=self, **kwargs)
def plot(self, *args, **kwargs): """ Plot pose object as a coordinate frame (superclass method) :param `**kwargs`: plotting options - ``X.plot()`` displays the pose ``X`` as a coordinate frame in either 2D or 3D. There are many options, see the links below. Example:: >>> X = SE3.Rx(0.3) >>> X.plot(frame='A', color='green') :seealso: :func:`~spatialmath.base.transforms3d.trplot`, :func:`~spatialmath.base.transforms2d.trplot2` """ if self.N == 2: tr.trplot2(self.A, *args, **kwargs) else: tr.trplot(self.A, *args, **kwargs)
def trplot(self, T, **kwargs): """ Define the transform to animate :param T: an SO(3) or SE(3) pose to be displayed as coordinate frame :type: numpy.ndarray, shape=(3,3) or (4,4) Is polymorphic with ``base.trplot`` and accepts the same parameters. This sets up the animation but doesn't execute it. :seealso: :func:`run` """ # stash the final value if tr.isrot(T): self.T = tr.r2t(T) else: self.T = T # draw axes at the origin tr.trplot(np.eye(4), axes=self, **kwargs)
def plot(self, *args, **kwargs): tr.trplot(tr.q2r(self._A), *args, **kwargs)
def tranimate(T, **kwargs): anim = Animate(**kwargs) tr.trplot(T, axes=anim, **kwargs) anim.run(**kwargs)
def plot(self, *args, **kwargs): if self.N == 2: tr.trplot2(self.A, *args, **kwargs) else: tr.trplot(self.A, *args, **kwargs)
import spatialmath.base as tr import matplotlib.pyplot as plt tr.trplot(tr.transl(1, 2, 3), frame='A', rviz=True, width=1) tr.trplot(tr.transl(3, 1, 2), color='red', width=3, frame='B') tr.trplot(tr.transl(4, 3, 1) @ tr.trotx(60, 'deg'), color='green', frame='c') plt.show()