Esempio n. 1
0
        public void Test_DownGt2Gt1Calib()
        {
            CalibrationConfig calib = new CalibrationConfig()
            {
                LeftHeightCalibGtPos = new PosXYZ(0, 0, 96.99),

                LeftHeightCalibGt1Pos = new PosXYZ(0, 0, 0),
                LeftHeightCalibGt2Pos = new PosXYZ(0, 0, 0),

                LeftHeightStandard = new PosXYZ(0, 0, 70.5),
            };


            List <PosXYZ> cpuPos = new List <PosXYZ>()
            {
                new PosXYZ(62.69, -64.8, 0.987),
                new PosXYZ(62.69, -96.8, 1.060),
                new PosXYZ(94.69, -96.8, 1.108),
                new PosXYZ(94.69, -64.8, 1.009),
                new PosXYZ(78.69, -80.8, 1.058),
            };


            List <PosXYZ> pins = new List <PosXYZ>()
            {
                new PosXYZ(46.69, -48.8, 2.117),
                new PosXYZ(46.69, -112.8, 2.131),
                new PosXYZ(110.69, -112.8, 2.179),
                new PosXYZ(110.69, -48.8, 2.051),
            };

            var plane = PlaneFitHelper.FitPlane(cpuPos.Select(p => p.X).ToArray(), cpuPos.Select(p => p.Y).ToArray(), cpuPos.Select(p => p.Z).ToArray());
        }
Esempio n. 2
0
        public void TestMethod_FitPlane()
        {
            double[] x = new[] { 1, 0d, -1 };
            double[] y = new[] { 1, 0d, 1 };
            double[] z = new[] { 0, 0d, 0 };


            var plane = PlaneFitHelper.FitPlane(x, y, z);

            Console.WriteLine($"Normal : {plane.Normal.ToString()}");
            Console.WriteLine($"Origin : {plane.Origin.ToString()}");

            Console.WriteLine(PlaneFitHelper.Point2Plane(plane, new[] { 1, 1, 1d }));
        }
Esempio n. 3
0
        public override void DoCalc(List <PosXYZ> pos)
        {
            Datum = PlaneFitHelper.FitPlane(pos.Select(p => p.X).ToArray(), pos.Select(p => p.Y).ToArray(), pos.Select(p => p.Z).ToArray());

            Data = pos.Select(p => PlaneFitHelper.Point2Plane(Datum as OrthogonalPlaneFit3, p.Data())).ToList();

            Max = Data.Max();
            Min = Data.Min();


            Value = Max - Min;

            //标记平面度超差点
            for (int i = 0; i < Data.Count; i++)
            {
                if (Data[i] > SpecMax / 2 || Data[i] < -SpecMax / 2)
                {
                    pos[i].Status = false;
                }
            }

            Success = true;
        }
Esempio n. 4
0
        public override void DoCalc(List <PosXYZ> pos)
        {
            if (Datum == null)
            {
                throw new Exception($"{GDTType} {Name} 基准不存在");
            }

            //todo test new parallelism calc
            //convert pos to pos on fit plane
            var plane  = PlaneFitHelper.FitPlane(pos.Select(p => p.X).ToArray(), pos.Select(p => p.Y).ToArray(), pos.Select(p => p.Z).ToArray());
            var newPos = new List <PosXYZ>();

            foreach (var p in pos)
            {
                var z = PlaneFitHelper.CalcZ(plane, p.X, p.Y);
                newPos.Add(new PosXYZ(p.X, p.Y, z));
            }

            //calc plane pos to datum
            Data = newPos.Select(p => PlaneFitHelper.Point2Plane(Datum as OrthogonalPlaneFit3, p.Data())).ToList();
            Max  = Data.Max();
            Min  = Data.Min();

            Value = Max - Min;


            //标记平行度超差点
            for (int i = 0; i < Data.Count; i++)
            {
                if (Data[i] > SpecMax || Data[i] < SpecMin)
                {
                    pos[i].Status = false;
                }
            }

            Success = true;
        }
Esempio n. 5
0
        public void Test_UpGtFlatness()
        {
            var settings = MachineSettings.Load(@".\Config2\settings.cfg");

            var project = FlatnessProject.Load(@".\Config2\A117NoFinNew.fprj");


            var upPos = project.ProductSettings.UpTestPositions.Skip(0).Take(8).ToList();

            int startIndex = 0;

            List <double> leftFlat  = new List <double>();
            List <double> leftMin   = new List <double>();
            List <double> leftMax   = new List <double>();
            List <double> rightFlat = new List <double>();
            List <double> rightMin  = new List <double>();
            List <double> rightMax  = new List <double>();

            {
                //fit left with 4 pos
                List <double[]> rawData = new List <double[]>();

                using (var fs = new FileStream(@".\Config2\left.csv", FileMode.Open))
                {
                    using (var sw = new StreamReader(fs))
                    {
                        var dataStr = sw.ReadLine()?.Split(',');
                        while (dataStr != null)
                        {
                            rawData.Add(new double[]
                            {
                                double.Parse(dataStr[13]),
                                double.Parse(dataStr[14]),
                                double.Parse(dataStr[15]),
                                double.Parse(dataStr[16]),
                                double.Parse(dataStr[17]),
                                double.Parse(dataStr[18]),
                                double.Parse(dataStr[19]),
                                double.Parse(dataStr[20]),
                            });
                            dataStr = sw.ReadLine()?.Split(',');
                        }
                    }
                }

                //fit plane
                for (int i = 0; i < rawData.Count; i++)
                {
                    for (int j = 0; j < upPos.Count; j++)
                    {
                        upPos[j].Z = rawData[i][startIndex + j];
                    }

                    var plane = PlaneFitHelper.FitPlane(
                        upPos.Select(p => p.X).ToArray(),
                        upPos.Select(p => p.Y).ToArray(),
                        upPos.Select(p => p.Z).ToArray());

                    var flat1 = upPos.Select(p => PlaneFitHelper.Point2Plane(plane, p.Data())).Min();
                    var flat2 = upPos.Select(p => PlaneFitHelper.Point2Plane(plane, p.Data())).Max();

                    var flatness = flat2 - flat1;

                    leftFlat.Add(flatness);
                    leftMin.Add(upPos.Select(p => p.Z).Min());
                    leftMax.Add(upPos.Select(p => p.Z).Max());
                }
            }

            {
                //fit left with 4 pos
                List <double[]> rawData = new List <double[]>();

                using (var fs = new FileStream(@".\Config2\right.csv", FileMode.Open))
                {
                    using (var sw = new StreamReader(fs))
                    {
                        var dataStr = sw.ReadLine()?.Split(',');
                        while (dataStr != null)
                        {
                            rawData.Add(new double[]
                            {
                                double.Parse(dataStr[13]),
                                double.Parse(dataStr[14]),
                                double.Parse(dataStr[15]),
                                double.Parse(dataStr[16]),
                                double.Parse(dataStr[17]),
                                double.Parse(dataStr[18]),
                                double.Parse(dataStr[19]),
                                double.Parse(dataStr[20]),
                            });
                            dataStr = sw.ReadLine()?.Split(',');
                        }
                    }
                }

                //fit plane
                for (int i = 0; i < rawData.Count; i++)
                {
                    for (int j = 0; j < upPos.Count; j++)
                    {
                        upPos[j].Z = rawData[i][startIndex + j];
                    }

                    var plane = PlaneFitHelper.FitPlane(
                        upPos.Select(p => p.X).ToArray(),
                        upPos.Select(p => p.Y).ToArray(),
                        upPos.Select(p => p.Z).ToArray());

                    var flat1 = upPos.Select(p => PlaneFitHelper.Point2Plane(plane, p.Data())).Min();
                    var flat2 = upPos.Select(p => PlaneFitHelper.Point2Plane(plane, p.Data())).Max();

                    var flatness = flat2 - flat1;

                    rightFlat.Add(flatness);
                    rightMin.Add(upPos.Select(p => p.Z).Min());
                    rightMax.Add(upPos.Select(p => p.Z).Max());
                }
            }

            Console.WriteLine("flat:\r\n");
            Console.WriteLine(string.Join(",", leftFlat.Select(f => f.ToString("F3"))));
            Console.WriteLine(string.Join(",", rightFlat.Select(f => f.ToString("F3"))));

            Console.WriteLine("zmin:\r\n");
            Console.WriteLine(string.Join(",", leftMin.Select(f => f.ToString("F3"))));
            Console.WriteLine(string.Join(",", rightMin.Select(f => f.ToString("F3"))));

            Console.WriteLine("zmax:\r\n");
            Console.WriteLine(string.Join(",", leftMax.Select(f => f.ToString("F3"))));
            Console.WriteLine(string.Join(",", rightMax.Select(f => f.ToString("F3"))));
        }