예제 #1
0
    def linear_move_poll(self, target_pos: Coordinate, speed: float = None, track_speed=False, current_pos=None):
        """
        Moves the robot linearly to a coordinate.
        :param target_pos: Coordinate for the target position.
        :param speed: Movement speed for tool.
        :param track_speed:
        :param current_pos:
        :return:
        """
        # Set speed
        if speed is not None:
            self.set_speed(speed, 'linear')

        # Only send command if any coordinates are passed, otherwise just set the speed
        if len(target_pos.values) > 0 and any(a is not None for a in target_pos.values):
            # Fill None values with current position to predict correct response
            if current_pos is None:
                # No need to do this twice
                current_pos = self.protocol.get_current_xyzabc()
            target_pos.add_axis(current_pos)
            target_pos.update_empty(current_pos)

            # Send move command
            self.protocol.linear_move(target_pos)

            # Wait until position is reached
            t, v = cmp_response(R3Protocol_Cmd.CURRENT_XYZABC, target_pos.to_melfa_response(), self.protocol.reader,
                                track_speed=track_speed)
            return t, v
        return None, None
예제 #2
0
    def go_home(self, option="") -> None:
        """
        Moves the robot to its current home point (current work coordinate origin or global safe position respectively)
        :return:
        """
        if self.work_coordinate_active:
            # Acquire new zero coordinate
            zero = Coordinate(self.zero.values, self.zero.axes)

            if option != "":
                zero = zero.reduce_to_axes(option, make_none=True)

            # Acquire current position to determine robot orientation
            current_position = self.protocol.reader.get_current_xyzabc()
            zero.add_axis(current_position)
            zero.update_empty(current_position)

            # Move to zero
            self.linear_move_poll(zero)
        else:
            self.go_safe_pos()