Example #1
0
    def calibrate(self, axis):
        ### click on calibrate X or Y button on dialpad
        index = int(self.content.ids["cur_panel"].text)
        x, y = inspection.get_panel_reference_1(self.project_data["Panel"],
                                                index - 1)
        if x == -1 and y == -1:
            return
        z = self.project_data["Setup"]["CameraParameters"]["FocusZ"]
        br = self.project_data["Setup"]["CameraParameters"]["IlluminationPWM"]
        # add offset for calibration
        centerx = x
        centery = y
        if axis == "X":
            x += self.project_data["Setup"]["CalibrationOffset"]
        if axis == "Y":
            y += self.project_data["Setup"]["CalibrationOffset"]

        self.content.ids["cur_X"].text = format(x, ".2f")
        self.content.ids["cur_Y"].text = format(y, ".2f")
        self.content.ids["cur_Z"].text = format(z, ".2f")
        ref = inspection.get_reference_1(self.project_data["InspectionPath"])
        self.set_part_overlay(ref)
        self.capture_video_inspectionpart = ref
        # inspect xyz printer
        gcode = robotcontrol.inspect_xyz(self.project_data, x, y, z, br,
                                         centerx, centery, index - 1, ref)
        self.queue_printer_command(gcode)
Example #2
0
    def get_panel_ref1(self):
        ### click on get1 button on dialpad
        index = int(self.content.ids["cur_panel"].text)
        x, y = inspection.get_panel_reference_1(self.project_data["Panel"],
                                                index - 1)
        if x == -1 and y == -1:
            x = self.project_data["Setup"]["TravelX"]
            y = self.project_data["Setup"]["TravelY"]
        z = self.project_data["Setup"]["TravelZ"]
        self.content.ids["cur_X"].text = format(x, ".2f")
        self.content.ids["cur_Y"].text = format(y, ".2f")
        self.content.ids["cur_Z"].text = format(z, ".2f")
        # set body and mask
        ref = inspection.get_reference_1(self.project_data["InspectionPath"])
        self.set_part_overlay(ref)
        self.capture_video_inspectionpart = ref

        # go xyz printer
        gcode = robotcontrol.go_xyz(self.project_data, x, y, z)
        self.queue_printer_command(gcode)
Example #3
0
    def set_reference_panel(self):
        #  show dialpad
        # print("ref")
        self.ids["tab_panel"].switch_to(self.ids["tab_panel"].tab_list[0])
        self.content = ControlPopup(
            controlXYZ=self.control_XYZ,
            set_panel_ref1=self.set_panel_ref1,
            set_panel_ref2=self.set_panel_ref2,
            get_panel_ref1=self.get_panel_ref1,
            get_panel_ref2=self.get_panel_ref2,
            calibrate=self.calibrate,
            teachin_reference=self.teachin_reference,
            cancel=self.dismiss_popup,
        )
        self.content.ids["cur_X"].text = format(
            self.project_data["Setup"]["TravelX"], ".2f")
        self.content.ids["cur_Y"].text = format(
            self.project_data["Setup"]["TravelY"], ".2f")
        self.content.ids["cur_Z"].text = format(
            self.project_data["Setup"]["TravelZ"], ".2f")
        self.content.ids["cur_panel"].text = "1"
        self._popup = Popup(
            title="Set reference point",
            content=self.content,
            size_hint=(0.4, 0.4),
            background_color=[0, 0, 0, 0.0],
        )
        self._popup.pos_hint = {"center_x": 0.8, "center_y": 0.8}
        self._popup.open()
        self.project_data["CADMode"] = "None"

        # set body and mask
        ref = inspection.get_reference_1(self.project_data["InspectionPath"])
        self.capture_video_inspectionpart = ref
        self.set_part_overlay(ref)

        # home printer
        gcode = robotcontrol.go_home(self.project_data)
        self.queue_printer_command(gcode)
Example #4
0
def panel_inspection(data, panelSelection):
    capture = []
    # header
    zp = data["Setup"]["CameraParameters"]["FocusZ"]
    br = data["Setup"]["CameraParameters"]["IlluminationPWM"]
    parameters = {
        "FocusZ": round(data["Setup"]["CameraParameters"]["FocusZ"], 2)
    }
    gcode = complete_template(data["GHeader"], parameters)
    # soldering backside?
    if data["InspectionSide"] == "Top":
        flip = 1
    else:
        flip = -1

    inspectionpath = data["InspectionPath"]
    inspection.get_sorted_inspectionpath(inspectionpath)

    # for each selected panel soldering
    for p, elem in enumerate(panelSelection):
        panel = data["Panel"][panelSelection[p]]
        # get panel data
        # teached panel coordinates
        # TODO add correction based on marker here
        xp1 = panel["RefX1"]
        yp1 = panel["RefY1"]
        xp2 = panel["RefX2"]
        yp2 = panel["RefY2"]
        if xp1 == -1 or xp2 == -1 or yp1 == -1 or yp2 == -1:
            print("error missing reference, skipping panel", p)
            continue
        # solder toolpath
        refNum1 = inspection.get_reference_1(inspectionpath)
        ref1 = inspectionpath[refNum1]
        xi1 = ref1["RefX"]
        yi1 = ref1["RefY"]
        refNum2 = inspection.get_reference_2(inspectionpath)
        ref2 = inspectionpath[refNum2]
        xi2 = ref2["RefX"]
        yi2 = ref2["RefY"]
        # print(xi1,yi1,xi2,yi2)
        # calculate transformation
        vp1 = array([xp1, yp1])
        vi1 = array([xi1, yi1])
        vp2 = array([xp2, yp2])
        vi2 = array([xi2, yi2])
        dvp = subtract(vp2, vp1)
        dvi = subtract(vi2, vi1)
        vplen = norm(dvp)
        vilen = norm(dvi)
        c = numpy.dot(dvp, dvi) / (vplen * vilen)
        # some numerical issues
        if c > 1.0:
            c = 1.0
        elif c < -1.0:
            c = -1.0
        radians = numpy.arccos(c)
        scale = vplen / vilen
        # print(vp1, vi1, vp2, vi2, dvp, dvi, vplen, vilen, c, scale, radians)
        # iterate over each capturing position
        for e in range(0,
                       inspection.get_number_inspectionpoints(inspectionpath)):
            ip = inspection.get_inspectionpoint(inspectionpath, e)
            ipindex = data["InspectionPath"][ip]["Partsdefinition"]
            if ipindex == -1:
                continue
            pd = data["PartsDefinition"]["PartsDefinition"][ipindex]
            xi = data["InspectionPath"][ip]["RefX"] * flip
            yi = data["InspectionPath"][ip]["RefY"]
            vi = array([xi, yi])
            xp, yp = get_printer_point(vi, -radians, scale, vi1, vp1)
            # create parameterlist
            gpos = inspect_xyz(data, xp, yp, zp, br, xp, yp, panelSelection[p],
                               ip)
            gcode += gpos
        gcode += complete_template(data["GFooter"], {})
        return gcode
Example #5
0
if unassiged == test:
    print("ok unassigned")
else:
    print("nok unassigned")

# get index of a part by designator
inspectionpath = prjdata['InspectionPath']
index = inspection.helper_get_index_by_designator(inspectionpath, "M1")
if index == 6:
    print("ok get index by designator")
else:
    print("nok get index by designator")

# select reference points
inspection.set_reference_1(inspectionpath, 51.8160, 51.8160)
ref1index = inspection.get_reference_1(inspectionpath)

inspection.set_reference_2(inspectionpath, 98.2980, 68.1990)
ref2index = inspection.get_reference_2(inspectionpath)
if ref1index == 6 and ref2index == 2:
    print("ok ref")
else:
    print("nok ref", refindex1, refindex2)

# marker bounding box
xb, yb, rotb, shapeb = inspection.get_bounding_box(partsdefinition, 0, "Body",
                                                   0, 0, 0, 0)
xm, ym, rotm, shapem = inspection.get_bounding_box(partsdefinition, 0, "Mask",
                                                   0, 0, 0, 0)

if [xb, yb, rotb] == [0.0, 1.1, 0.0] and [xm, ym, rotm] == [1.5, 0.0, 0.0]: