Esempio n. 1
0
        // will go to the nearest hole to the next part and display what it will pick up gooz
        public bool GoToNextComponent(TapeObj to)
        {
            SetCurrentTapeMeasurement(to.TapeType); //setup tape type to measure

            if (to.FirstPart != null)
            {
                Cnc.CNC_XY(to.GetPartBasedLocation(to.CurrentPartIndex()));
                return(true);
            }
            if (to.FirstHole == null)
            {
                MainForm.ShowSimpleMessageBox("First hole not set and part not set - calibrate this first");
                return(false);
            }

            if (to.IsLocationBased)
            {
                Cnc.CNC_XY(GetLocationBasedComponent(to));
            }
            else
            {
                MainForm.cameraView.downSettings.FindCircles = true;
                // move to closest hole to the part we are looking for
                Cnc.CNC_XY(to.GetNearestCurrentPartHole());
                var hole = MainForm.FindPositionAndMoveToClosest(Shapes.ShapeTypes.Circle, 1.5, .05);
                if (hole == null)
                {
                    //MainForm.ShowSimpleMessageBox("Unable to center on nearest hole");
                    return(false);
                }
                MainForm.cameraView.DownCameraReset();

                // move camera on top of the part, and then move from there to the part to pick up
                var offset = to.GetCurrentPartLocation() - to.GetNearestCurrentPartHole();
                Cnc.CNC_XY(hole + offset);
            }
            var c = MainForm.cameraView.downVideoProcessing.FrameCenter;

            MainForm.cameraView.downVideoProcessing.Arrows.Add(new Shapes.Arrow(c.X, c.Y, to.PartAngle, 100));
            return(true);
        }
Esempio n. 2
0
        // will go to the nearest hole to the next part and display what it will pick up gooz
        public bool GoToNextComponent(TapeObj to)
        {
            if (to.IsLocationBased)
            {
                Cnc.CNC_XY(GetLocationBasedComponent(to));
            }
            else
            {
                SetCurrentTapeMeasurement(to.TapeType); //setup tape type to measure

                if (to.FirstPart != null)
                {
                    Cnc.CNC_XY(to.GetPartBasedLocation(to.CurrentPartIndex()));
                    return true;
                }
                if (to.FirstHole == null)
                {
                    MainForm.ShowSimpleMessageBox("First hole not set and part not set - calibrate this first");
                    return false;
                }

                MainForm.cameraView.downSettings.FindCircles = true;
                // move to closest hole to the part we are looking for
                Cnc.CNC_XY(to.GetNearestCurrentPartHole());
                var hole = MainForm.FindPositionAndMoveToClosest(Shapes.ShapeTypes.Circle, 1.5, .05);
                if (hole == null)
                {
                    //MainForm.ShowSimpleMessageBox("Unable to center on nearest hole");
                    return false;
                }
                MainForm.cameraView.DownCameraReset();

                // move camera on top of the part, and then move from there to the part to pick up
                var offset = to.GetCurrentPartLocation() - to.GetNearestCurrentPartHole();
                Cnc.CNC_XY(hole + offset);
            }
            var c = MainForm.cameraView.downVideoProcessing.FrameCenter;
            MainForm.cameraView.downVideoProcessing.Arrows.Add(new Shapes.Arrow(c.X,c.Y, to.PartAngle, 100) );
            return true;
        }
Esempio n. 3
0
        public PartLocation GetNextComponentPartLocation(TapeObj tapeObj)
        {
            if (tapeObj == null) return null;
            MainForm.DisplayText("GotoNextPart_m(), tape id: " + tapeObj.ID);

            //Load & Parse Data
            if (!tapeObj.IsFullyCalibrated) {
                MainForm.ShowSimpleMessageBox("Tape " + tapeObj.ID + " is not yet calibrated.  Please do so and retry");
                return null;
            }

            PartLocation targetLocation = tapeObj.GetCurrentPartLocation();
            MainForm.DisplayText("Part " + tapeObj.CurrentPartIndex() + "  Source Location = " + targetLocation, Color.Blue);

            // see if part exists for part based detection
            if (tapeObj.TemplateBased) {
                Global.Instance.mainForm.cameraView.DownCameraReset();
                if (!MainForm.Cnc.CNC_XY(targetLocation)) return null;
                var thing = MainForm.GoToClosestThing(Shapes.ShapeTypes.Fiducial, 1, .2, null, tapeObj.TemplateFilename, .75);
                if (thing == null) {
                    MainForm.DisplayText("No Part Detected At This Location", Color.Red);
                    return null;
                }
                MainForm.DisplayText("Part Detected : " + thing);
            }

            if (tapeObj.IsLocationBased) {
                targetLocation = GetLocationBasedComponent(tapeObj);
            } else
            // enhanced part detection
            if (tapeObj.FirstHole != null) {
                SetCurrentTapeMeasurement(tapeObj.TapeType);
                Cnc.CNC_XY(tapeObj.GetNearestCurrentPartHole());
                var hole = MainForm.GoToClosestThing(Shapes.ShapeTypes.Circle, 1.5, .1);
                if (hole == null) {
                    MainForm.DisplayText("Unable to detect part hole, aborting");
                    return null;
                }
                var offset = tapeObj.GetCurrentPartLocation() - tapeObj.GetNearestCurrentPartHole();
                targetLocation = hole.ToPartLocation() + offset;
                MainForm.cameraView.DownCameraReset();
            }

            //------------------- PART SPECIFIC LOGIC GOES HERE --------------------//
            if (tapeObj.PartType == "QFN") {
                MainForm.DisplayText("USING ENHANCE PART PICKUP", Color.HotPink);
                if (!MainForm.Cnc.CNC_XY(targetLocation)) return null;
                // setup view
                SetCurrentTapeMeasurement(tapeObj.TapeType);
                MainForm.cameraView.downSettings.FindRectangles = true;

                // MainForm.cameraView.downVideoProcessing.FindRectangles = true;
                // move closer and get exact coordinates plus rotation
                var rect = (Shapes.Rectangle) MainForm.GoToClosestThing(Shapes.ShapeTypes.Rectangle, 1.5, .025);

                if (rect == null) {
                    MainForm.cameraView.DownCameraReset();
                    return null;
                }
                Global.DoBackgroundWork(500);
                var rectAngle = rect.AngleOffsetFrom90();

                targetLocation = rect.ToPartLocation();
                targetLocation.A = tapeObj.OriginalPartOrientationVector.ToDegrees() + rectAngle;

                MainForm.cameraView.DownCameraReset();
            }

            return targetLocation;
        }
Esempio n. 4
0
        public PartLocation GetNextComponentPartLocation(TapeObj tapeObj)
        {
            if (tapeObj == null)
            {
                return(null);
            }
            MainForm.DisplayText("GotoNextPart_m(), tape id: " + tapeObj.ID);

            //Load & Parse Data
            if (!tapeObj.IsFullyCalibrated)
            {
                MainForm.ShowSimpleMessageBox("Tape " + tapeObj.ID + " is not yet calibrated.  Please do so and retry");
                return(null);
            }

            PartLocation targetLocation = tapeObj.GetCurrentPartLocation();

            MainForm.DisplayText("Part " + tapeObj.CurrentPartIndex() + "  Source Location = " + targetLocation, Color.Blue);

            // see if part exists for part based detection
            if (tapeObj.TemplateBased)
            {
                Global.Instance.mainForm.cameraView.DownCameraReset();
                if (!MainForm.Cnc.CNC_XY(targetLocation))
                {
                    return(null);
                }
                var thing = MainForm.GoToClosestThing(Shapes.ShapeTypes.Fiducial, 1, .2, null, tapeObj.TemplateFilename, .75);
                if (thing == null)
                {
                    MainForm.DisplayText("No Part Detected At This Location", Color.Red);
                    return(null);
                }
                MainForm.DisplayText("Part Detected : " + thing);
            }


            if (tapeObj.IsLocationBased)
            {
                targetLocation = GetLocationBasedComponent(tapeObj);
            }
            else
            // enhanced part detection
            if (tapeObj.FirstHole != null)
            {
                SetCurrentTapeMeasurement(tapeObj.TapeType);
                Cnc.CNC_XY(tapeObj.GetNearestCurrentPartHole());
                var hole = MainForm.GoToClosestThing(Shapes.ShapeTypes.Circle, 1.5, .1);
                if (hole == null)
                {
                    MainForm.DisplayText("Unable to detect part hole, aborting");
                    return(null);
                }
                var offset = tapeObj.GetCurrentPartLocation() - tapeObj.GetNearestCurrentPartHole();
                targetLocation = hole.ToPartLocation() + offset;
                MainForm.cameraView.DownCameraReset();
            }

            //------------------- PART SPECIFIC LOGIC GOES HERE --------------------//
            if (tapeObj.PartType == "QFN")
            {
                MainForm.DisplayText("USING ENHANCE PART PICKUP", Color.HotPink);
                if (!MainForm.Cnc.CNC_XY(targetLocation))
                {
                    return(null);
                }
                // setup view
                SetCurrentTapeMeasurement(tapeObj.TapeType);
                MainForm.cameraView.downSettings.FindRectangles = true;

                // MainForm.cameraView.downVideoProcessing.FindRectangles = true;
                // move closer and get exact coordinates plus rotation
                var rect = (Shapes.Rectangle)MainForm.GoToClosestThing(Shapes.ShapeTypes.Rectangle, 1.5, .025);

                if (rect == null)
                {
                    MainForm.cameraView.DownCameraReset();
                    return(null);
                }
                Global.DoBackgroundWork(500);
                var rectAngle = rect.AngleOffsetFrom90();

                targetLocation   = rect.ToPartLocation();
                targetLocation.A = tapeObj.OriginalPartOrientationVector.ToDegrees() + rectAngle;

                MainForm.cameraView.DownCameraReset();
            }

            return(targetLocation);
        }