예제 #1
0
        /// <summary>
        /// 背光定位,不规则区域,计算并发送角度到robot1
        /// </summary>
        /// <param name="precisePos">精定位拍照位置</param>
        /// <param name="cmdAngle">与bot的协议,表示拍照ok</param>
        /// <param name="cmdError">与bot的协议,表示拍照失败</param>
        /// <param name="threadR">角度阈值</param>
        /// <param name="deltar">算子直接获得的角度</param>
        /// <param name="displayType">画面设置,影响角度计算</param>
        /// <param name="id">unique id</param>
        /// <param name="ifRecord">是否进行数据记录</param>
        /// <param name="r">输出计算后不要补正的角度偏差</param>
        /// <returns></returns>
        public static bool BlobAngleCalc(double deltar, Point4D precisePos, string cmdAngle, string cmdError,
                                         double threadR, BackLightDisplay_Enum displayType, int id, bool ifRecord, out double r)
        {
            r = 0;
            try
            {
                r = GetDeltaR(deltar, displayType);

                if (Math.Abs(r) > threadR)
                {
                    ShowAlarm("精确定位处角度:" + r.ToString(ReservDigits) + "超过设定阈值:" + threadR.ToString(ReservDigits));
                    LogicRobot.L_I.WriteRobotCMD(cmdError);
                    return(false);
                }

                ShowState("玻璃精确定位处角度:" + r.ToString(ReservDigits));
                //发送角度让机器人调整,第一次拍照结果
                LogicRobot.L_I.WriteRobotCMD(precisePos.Add(3, r), cmdAngle);
                return(true);
            }
            catch (Exception ex)
            {
                Log.L_I.WriteError(ClassName, ex);
                return(false);
            }
            finally
            {
                if (ifRecord)
                {
                    RecordPreciseData(id, "角度" + r.ToString());
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 用于不规则区域角度补偿值的计算,将不规则区域直接获得的角度值转换成补正的偏差角度
        /// </summary>
        /// <param name="r">不规则区域获得的R_J</param>
        /// <param name="displayType">背光显示方向</param>
        /// <returns></returns>
        public static double GetDeltaR(double r, BackLightDisplay_Enum displayType)
        {
            double deltaR = Math.Round(r, 3);

            if (displayType == BackLightDisplay_Enum.Vertical)
            {
                deltaR += r < 0 ? 90 : -90;
            }
            return(deltaR);
        }
예제 #3
0
 /// <summary>
 /// 背光一次定位偏差计算
 /// </summary>
 /// <param name="pt2Src">像素坐标,精定位处获取的计算结果</param>
 /// <param name="pt2Rc">旋转中心</param>
 /// <param name="r">角度补偿,即需要旋转的角度</param>
 /// <param name="ratio">相机系数</param>
 /// <param name="type">背光方向</param>
 /// <param name="srcAngle">精定位处玻璃角度</param>
 /// <param name="dstAngle">目标点玻璃角度</param>
 /// <param name="botAngle">机器人放置角度</param>
 /// <param name="displayAngle">画面显示角度</param>
 /// <param name="blAngle">背光角度</param>
 public static void Verify(Point2D pt2Src, Point2D pt2Rc, double r, double ratio, BackLightDisplay_Enum type,
                           double srcAngle, double dstAngle, double botAngle, double displayAngle, double blAngle)
 {
     try
     {
         r = GetDeltaR(r, type);
         Point2D pt2AfterR = new FunCalibRotate().GetPoint_AfterRotation(r / 180 * Math.PI, pt2Rc, pt2Src);
         Point2D delta     = pt2AfterR - pt2Rc;
         delta = GetDeviationForBot(delta, botAngle, displayAngle, blAngle, srcAngle, dstAngle);
         delta = new Point2D(delta.DblValue1 * ratio, delta.DblValue2 * ratio);
         ShowState(string.Format("一次拍照计算的偏差结果:X:{0}/Y:{1}",
                                 delta.DblValue1.ToString(ReservDigits),
                                 delta.DblValue2.ToString(ReservDigits)));
     }
     catch (Exception ex)
     {
         Log.L_I.WriteError(ClassName, ex);
     }
 }