Пример #1
0
    def Rx(cls, theta, unit='rad', t=None):
        """
        Create anSE(3) pure rotation about the X-axis

        :param θ: rotation angle about X-axis
        :type θ: float
        :param unit: angular units: 'rad' [default], or 'deg'
        :type unit: str
        :param t: translation, optional
        :type t: 3-element array-like
        :return: SE(3) matrix
        :rtype: SE3 instance

        - ``SE3.Rx(θ)`` is an SE(3) rotation of θ radians about the x-axis
        - ``SE3.Rx(θ, "deg")`` as above but θ is in degrees
        - ``SE3.Rx(θ, t=T)`` as above but also sets the translational component

        If ``θ`` is an array then the result is a sequence of rotations defined
        by consecutive elements.

        .. note:: The translation option only works for the scalar θ case.

        Example:

        .. runblock:: pycon

            >>> SE3.Rx(0.3)
            >>> SE3.Rx([0.3, 0.4])

        :seealso: :func:`~spatialmath.base.transforms3d.trotx`
        :SymPy: supported
        """
        return cls(
            [base.trotx(x, t=t, unit=unit) for x in base.getvector(theta)],
            check=False)
Пример #2
0
    def test_T_real(self):
        fl = 1.543
        rx = rp.ET.TRx(joint=86)
        ry = rp.ET.TRy(joint=86)
        rz = rp.ET.TRz(joint=86)
        tx = rp.ET.Ttx(joint=86)
        ty = rp.ET.Tty(joint=86)
        tz = rp.ET.Ttz(joint=86)

        nt.assert_array_almost_equal(rx.T(fl), sm.trotx(fl))
        nt.assert_array_almost_equal(ry.T(fl), sm.troty(fl))
        nt.assert_array_almost_equal(rz.T(fl), sm.trotz(fl))
        nt.assert_array_almost_equal(tx.T(fl), sm.transl(fl, 0, 0))
        nt.assert_array_almost_equal(ty.T(fl), sm.transl(0, fl, 0))
        nt.assert_array_almost_equal(tz.T(fl), sm.transl(0, 0, fl))
Пример #3
0
    def test_T_real_2(self):
        fl = 1.543
        rx = rp.ET.rx()
        ry = rp.ET.ry()
        rz = rp.ET.rz()
        tx = rp.ET.tx()
        ty = rp.ET.ty()
        tz = rp.ET.tz()

        nt.assert_array_almost_equal(rx.T(fl).A, sm.trotx(fl))
        nt.assert_array_almost_equal(ry.T(fl).A, sm.troty(fl))
        nt.assert_array_almost_equal(rz.T(fl).A, sm.trotz(fl))
        nt.assert_array_almost_equal(tx.T(fl).A, sm.transl(fl, 0, 0))
        nt.assert_array_almost_equal(ty.T(fl).A, sm.transl(0, fl, 0))
        nt.assert_array_almost_equal(tz.T(fl).A, sm.transl(0, 0, fl))
Пример #4
0
 def Rx(cls, theta, unit='rad'):
     """
     Create SE(3) pure rotation about the X-axis
 
     :param theta: rotation angle about X-axis
     :type theta: float
     :param unit: angular units: 'rad' [default], or 'deg'
     :type unit: str
     :return: 4x4 homogeneous transformation matrix
     :rtype: SE3 instance
 
     - ``SE3.Rx(THETA)`` is an SO(3) rotation of THETA radians about the x-axis
     - ``SE3.Rx(THETA, "deg")`` as above but THETA is in degrees
     """
     return cls([tr.trotx(x, unit) for x in argcheck.getvector(theta)])
Пример #5
0
    def Rx(cls, theta, unit='rad'):
        """
        Create SE(3) pure rotation about the X-axis

        :param theta: rotation angle about X-axis
        :type theta: float
        :param unit: angular units: 'rad' [default], or 'deg'
        :type unit: str
        :return: 4x4 homogeneous transformation matrix
        :rtype: SE3 instance

        - ``SE3.Rx(THETA)`` is an SO(3) rotation of THETA radians about the x-axis
        - ``SE3.Rx(THETA, "deg")`` as above but THETA is in degrees
        
        If ``theta`` is an array then the result is a sequence of rotations defined by consecutive
        elements.
        """
        return cls([tr.trotx(x, unit) for x in argcheck.getvector(theta)],
                   check=False)
Пример #6
0
    def test_T_real(self):
        fl = 1.543
        rx = rp.ET.TRx()
        ry = rp.ET.TRy()
        rz = rp.ET.TRz()
        tx = rp.ET.Ttx()
        ty = rp.ET.Tty()
        tz = rp.ET.Ttz()

        rx.j = 86
        ry.j = 86
        rz.j = 86
        tx.j = 86
        ty.j = 86
        tz.j = 86

        nt.assert_array_almost_equal(rx.T(fl).A, sm.trotx(fl))
        nt.assert_array_almost_equal(ry.T(fl).A, sm.troty(fl))
        nt.assert_array_almost_equal(rz.T(fl).A, sm.trotz(fl))
        nt.assert_array_almost_equal(tx.T(fl).A, sm.transl(fl, 0, 0))
        nt.assert_array_almost_equal(ty.T(fl).A, sm.transl(0, fl, 0))
        nt.assert_array_almost_equal(tz.T(fl).A, sm.transl(0, 0, fl))
Пример #7
0
    def test_TRx(self):
        fl = 1.543

        nt.assert_array_almost_equal(rp.ET.TRx(fl).T(), sm.trotx(fl))
        nt.assert_array_almost_equal(rp.ET.TRx(-fl).T(), sm.trotx(-fl))
        nt.assert_array_almost_equal(rp.ET.TRx(0).T(), sm.trotx(0))
Пример #8
0
    def test_ets_var(self):
        ets = rp.ET.rx() * rp.ET.tx()

        nt.assert_array_almost_equal(ets[0].T(1).A, sm.trotx(1))
        nt.assert_array_almost_equal(ets[1].T(2).A, sm.transl(2, 0, 0))
Пример #9
0
 def update(frame, a):
     s = frame / 100.0
     T = tr.transl(0.5 * s, 0.5 * s, 0.5 * s) @ tr.trotx(math.pi * s)
     a.draw(T)
     return a.artists()
Пример #10
0
    def test_ets(self):
        ets = rp.ETS.rx(1) * rp.ETS.tx(2)

        nt.assert_array_almost_equal(ets[0].T(), sm.trotx(1))
        nt.assert_array_almost_equal(ets[1].T(), sm.transl(2, 0, 0))
Пример #11
0
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()