Пример #1
0
    def __init__(self, tcp_frame):

        self.model = []
        self.tool0_frame = Frame.worldXY()
        self.tcp_frame = tcp_frame
        self.transformation_tool0_tcp = Transformation.from_frame_to_frame(self.tcp_frame, self.tool0_frame)
        self.transformation_tcp_tool0 = Transformation.from_frame_to_frame(self.tool0_frame, self.tcp_frame)
Пример #2
0
 def set_base(self, base_frame):
     # move to UR !!!! ???
     self.base_frame = base_frame
     # transformation matrix from world coordinate system to robot coordinate system
     self.transformation_WCS_RCS = Transformation.from_frame_to_frame(Frame.worldXY(), self.base_frame)
     # transformation matrix from robot coordinate system to world coordinate system
     self.transformation_RCS_WCS = Transformation.from_frame_to_frame(self.base_frame, Frame.worldXY())
Пример #3
0
    def calculate_fixed_transformation(self, position):
        """Returns an identity transformation.

        The fixed joint is is not really a joint because it cannot move. All
        degrees of freedom are locked.
        """
        return Transformation()
Пример #4
0
    def transform(self, transformation):
        """Transform the frame.

        Parameters
        ----------
        transformation : :class:`Transformation`
            The transformation used to transform the Frame.

        Examples
        --------
        >>> from compas.geometry import Frame
        >>> from compas.geometry import Transformation
        >>> f1 = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
        >>> T = Transformation.from_frame(f1)
        >>> f2 = Frame.worldXY()
        >>> f2.transform(T)
        >>> f1 == f2
        True

        """
        T = transformation * Transformation.from_frame(self)
        point = T.translation
        xaxis, yaxis = T.basis_vectors
        self.point = point
        self.xaxis = xaxis
        self.yaxis = yaxis
Пример #5
0
    def represent_frame_in_global_coordinates(self, frame):
        """Represents another frame in the local coordinate system in the world
            coordinate system.

        Parameters
        ----------
        frame: :class:`Frame`
            A frame in the local coordinate system.

        Returns
        -------
        :class:`Frame`
            A frame in the world coordinate system.

        Examples
        --------
        >>> from compas.geometry import Frame
        >>> f = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
        >>> pw1 = Frame([1, 1, 1], [0.707, 0.707, 0], [-0.707, 0.707, 0])
        >>> pf = f.represent_frame_in_local_coordinates(pw1)
        >>> pw2 = f.represent_frame_in_global_coordinates(pf)
        >>> allclose(pw1.point, pw2.point)
        True
        >>> allclose(pw1.xaxis, pw2.xaxis)
        True
        >>> allclose(pw1.yaxis, pw2.yaxis)
        True

        """
        T = Transformation.from_frame(self)
        f = frame.copy()
        f.transform(T)
        return f
Пример #6
0
 def get_tool0_transformation(self, T5):
     """Get the transformation to reach tool0_frame.
     """
     return T5 * Transformation.from_frame(self.tool0_frame)
Пример #7
0
 def get_tcp_frame_from_tool0_frame(self, frame_tool0):
     """Get the tcp frame from the tool0 frame.
     """
     T = Transformation.from_frame(frame_tool0)
     return Frame.from_transformation(T * self.transformation_tcp_tool0)
Пример #8
0
 def get_tool0_frame_from_tcp_frame(self, frame_tcp):
     """Get the tool0 frame (frame at robot) from the tool frame (frame_tcp).
     """
     T = Transformation.from_frame(frame_tcp)
     return Frame.from_transformation(T * self.transformation_tool0_tcp)
Пример #9
0
 def init_transformation(self):
     if self.init_origin:
         return Transformation.from_frame(self.init_origin)
     else:
         return Transformation()
Пример #10
0
 def current_transformation(self):
     if self.origin:
         return Transformation.from_frame(self.origin)
     else:
         return Transformation()
Пример #11
0
def _to_xform(m):
    m = m if len(m) == 16 else m + [0, 0, 0, 1]
    return xform_from_transformation(Transformation.from_list(m))
Пример #12
0
# ==============================================================================
# Main
# ==============================================================================

if __name__ == '__main__':

    f1 = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
    R = Rotation.from_frame(f1)
    f2 = Frame.from_rotation(R, point=f1.point)
    print(f1 == f2)

    print(f2)

    f1 = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
    T = Transformation.from_frame(f1)
    f2 = Frame.from_transformation(T)
    print(f1 == f2)

    ea1 = [0.5, 0.4, 0.8]
    M = matrix_from_euler_angles(ea1)
    f = Frame.from_matrix(M)
    ea2 = f.euler_angles()
    print(allclose(ea1, ea2))

    q1 = [0.945, -0.021, -0.125, 0.303]
    f = Frame.from_quaternion(q1, point=[1., 1., 1.])
    q2 = f.quaternion
    print(allclose(q1, q2, tol=1e-03))

    aav1 = [-0.043, -0.254, 0.617]