20230411Change
This commit is contained in:
parent
8a92dd3eea
commit
9b6bd5321a
@ -81,7 +81,7 @@ namespace BRS.Common.Model
|
|||||||
[Category("机械臂配置项")]
|
[Category("机械臂配置项")]
|
||||||
[Description("拧紧轴推进距离")]
|
[Description("拧紧轴推进距离")]
|
||||||
[DisplayName("拧紧轴推进距离")]
|
[DisplayName("拧紧轴推进距离")]
|
||||||
public float NIJ_DisD { get; set; } = -99;
|
public float NIJ_DisD { get; set; }
|
||||||
|
|
||||||
public string GetDisplayText()
|
public string GetDisplayText()
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,7 @@ namespace BRS.Process.A020
|
|||||||
{
|
{
|
||||||
public partial class A020Process
|
public partial class A020Process
|
||||||
{
|
{
|
||||||
private bool IsTesting { get; set; } = true;
|
private bool IsTesting { get; set; } = false;
|
||||||
public bool IsSingleStepOperating { get; set; } = false;
|
public bool IsSingleStepOperating { get; set; } = false;
|
||||||
public bool IsArrive { get; set; } = false;//判断机械臂携带拧紧轴是否到位
|
public bool IsArrive { get; set; } = false;//判断机械臂携带拧紧轴是否到位
|
||||||
|
|
||||||
@ -29,11 +29,12 @@ namespace BRS.Process.A020
|
|||||||
private bool IsTough { get; set; } = false;//是否拧紧
|
private bool IsTough { get; set; } = false;//是否拧紧
|
||||||
|
|
||||||
int ShiJiaoVecCountFlag1 = 0;// 相机的示教点索引
|
int ShiJiaoVecCountFlag1 = 0;// 相机的示教点索引
|
||||||
float Distance_DisD = 0;//拧紧轴推进距离100
|
|
||||||
|
|
||||||
|
//float NJZ_T = (float)102.548;
|
||||||
|
|
||||||
|
|
||||||
DeviceModel AModeTypeRun = new DeviceModel();//相机机械臂全局配置(务必要有)
|
DeviceModel AModeTypeRun = new DeviceModel();//相机机械臂全局配置(务必要有)
|
||||||
|
|
||||||
private void StopMachineClosing(PLCBase MelsecPlc, TCPSeverBase TcpSeverBase1)
|
private void StopMachineClosing(PLCBase MelsecPlc, TCPSeverBase TcpSeverBase1)
|
||||||
{
|
{
|
||||||
if (MelsecPlc != null && MelsecPlc.InitialConfig.IsEnabled)
|
if (MelsecPlc != null && MelsecPlc.InitialConfig.IsEnabled)
|
||||||
@ -55,6 +56,7 @@ namespace BRS.Process.A020
|
|||||||
/* 设备对象 */
|
/* 设备对象 */
|
||||||
private ThridLibray.IDevice m_dev;
|
private ThridLibray.IDevice m_dev;
|
||||||
Mat Mat_CamA = new Mat();
|
Mat Mat_CamA = new Mat();
|
||||||
|
|
||||||
Bitmap Bit_Image = null;
|
Bitmap Bit_Image = null;
|
||||||
// private ThridLibray.IDevice m_dev1;
|
// private ThridLibray.IDevice m_dev1;
|
||||||
// private ThridLibray.IDevice m_dev2;
|
// private ThridLibray.IDevice m_dev2;
|
||||||
@ -139,7 +141,7 @@ namespace BRS.Process.A020
|
|||||||
Catcher.Show(exception);
|
Catcher.Show(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool CamA = false;
|
bool CamA = true;
|
||||||
private void OnImageGrabbed(Object sender, GrabbedEventArgs e)
|
private void OnImageGrabbed(Object sender, GrabbedEventArgs e)
|
||||||
{
|
{
|
||||||
Mat_CamA = null;
|
Mat_CamA = null;
|
||||||
@ -245,12 +247,40 @@ namespace BRS.Process.A020
|
|||||||
public static void Contour_Get(Mat mat, List<OpenCvSharp.Point[]> Lastcontours)
|
public static void Contour_Get(Mat mat, List<OpenCvSharp.Point[]> Lastcontours)
|
||||||
{
|
{
|
||||||
//高斯模糊
|
//高斯模糊
|
||||||
Mat dst = new Mat();
|
//Mat dst = new Mat();
|
||||||
|
//OpenCvSharp.Size ksize = new OpenCvSharp.Size(3, 3);
|
||||||
|
//Cv2.GaussianBlur(mat, dst, ksize, 0);
|
||||||
|
//Mat gray = new Mat();
|
||||||
|
//Cv2.CvtColor(dst, gray, ColorConversionCodes.BGR2GRAY);
|
||||||
|
Mat binary = mat.Clone();
|
||||||
|
Cv2.Threshold(mat, binary, 0, 255, ThresholdTypes.BinaryInv | ThresholdTypes.Otsu);
|
||||||
|
//查找轮廓
|
||||||
|
//List<List<Point>> contours = new List<List<Point>>();
|
||||||
|
OpenCvSharp.Point[][] contours = null;
|
||||||
|
HierarchyIndex[] hierarchly;
|
||||||
|
Cv2.FindContours(binary, out contours, out hierarchly, RetrievalModes.Tree, ContourApproximationModes.ApproxSimple, new OpenCvSharp.Point(0, 0));
|
||||||
|
|
||||||
|
for (int i = 0; i < contours.Length; i++)
|
||||||
|
{
|
||||||
|
double length = Cv2.ArcLength(contours[i], true);
|
||||||
|
if (length > 300 && length < 550)
|
||||||
|
{
|
||||||
|
Lastcontours.Add(contours[i]);
|
||||||
|
Console.WriteLine(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void Contour3_Get(Mat mat, List<OpenCvSharp.Point[]> Lastcontours)
|
||||||
|
{
|
||||||
|
//高斯模糊
|
||||||
|
//Mat Image = Cv2.ImRead(@"C:\徐敏育\项目\螺丝机研发\P1\1.png");
|
||||||
|
Mat dst = mat.Clone();
|
||||||
OpenCvSharp.Size ksize = new OpenCvSharp.Size(3, 3);
|
OpenCvSharp.Size ksize = new OpenCvSharp.Size(3, 3);
|
||||||
Cv2.GaussianBlur(mat, dst, ksize, 0);
|
// Cv2.GaussianBlur(mat, dst, ksize, 0);
|
||||||
Mat gray = new Mat();
|
Mat gray = mat.Clone();
|
||||||
Cv2.CvtColor(dst, gray, ColorConversionCodes.BGR2GRAY);
|
Cv2.CvtColor(dst, gray, ColorConversionCodes.BGR2GRAY);
|
||||||
Mat binary = new Mat();
|
Mat binary = gray.Clone();
|
||||||
Cv2.Threshold(gray, binary, 0, 255, ThresholdTypes.BinaryInv | ThresholdTypes.Otsu);
|
Cv2.Threshold(gray, binary, 0, 255, ThresholdTypes.BinaryInv | ThresholdTypes.Otsu);
|
||||||
//查找轮廓
|
//查找轮廓
|
||||||
//List<List<Point>> contours = new List<List<Point>>();
|
//List<List<Point>> contours = new List<List<Point>>();
|
||||||
@ -261,8 +291,13 @@ namespace BRS.Process.A020
|
|||||||
for (int i = 0; i < contours.Length; i++)
|
for (int i = 0; i < contours.Length; i++)
|
||||||
{
|
{
|
||||||
double length = Cv2.ArcLength(contours[i], true);
|
double length = Cv2.ArcLength(contours[i], true);
|
||||||
if (length > 300 && length < 400)
|
|
||||||
|
|
||||||
|
|
||||||
|
//Console.ReadKey();
|
||||||
|
if (length > 500 && length < 600)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(length);
|
||||||
Lastcontours.Add(contours[i]);
|
Lastcontours.Add(contours[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +313,7 @@ namespace BRS.Process.A020
|
|||||||
{
|
{
|
||||||
Mat SrcImage = image.Clone();
|
Mat SrcImage = image.Clone();
|
||||||
// 固定路径的模板图像
|
// 固定路径的模板图像
|
||||||
Mat Image = Cv2.ImRead(@"D:\MelsecPLCReadWrite\Bk\20230330\1.png");
|
Mat Image = Cv2.ImRead(@"D:\testData\Model_P\1.jpg");
|
||||||
Mat TempleteImage = Image.Clone();
|
Mat TempleteImage = Image.Clone();
|
||||||
|
|
||||||
// Point[][] contours1 = new Point[][] { };
|
// Point[][] contours1 = new Point[][] { };
|
||||||
@ -286,9 +321,10 @@ namespace BRS.Process.A020
|
|||||||
List<OpenCvSharp.Point[]> contours1 = new List<OpenCvSharp.Point[]>();
|
List<OpenCvSharp.Point[]> contours1 = new List<OpenCvSharp.Point[]>();
|
||||||
List<OpenCvSharp.Point[]> contours2 = new List<OpenCvSharp.Point[]>();
|
List<OpenCvSharp.Point[]> contours2 = new List<OpenCvSharp.Point[]>();
|
||||||
|
|
||||||
|
Contour3_Get(TempleteImage, contours2);
|
||||||
Contour_Get(SrcImage, contours1);
|
Contour_Get(SrcImage, contours1);
|
||||||
Contour_Get(TempleteImage, contours2);
|
Cv2.ImWrite(@"D:\MelsecPLCReadWrite\Bk\20230330\TempleteImage.jpg", SrcImage);
|
||||||
|
Cv2.ImWrite(@"D:\MelsecPLCReadWrite\Bk\20230330\SrcImage.jpg", TempleteImage);
|
||||||
// Hu矩计算
|
// Hu矩计算
|
||||||
//Moments mm2 = Cv2.Moments(contours2[0]); // 先计算几何矩
|
//Moments mm2 = Cv2.Moments(contours2[0]); // 先计算几何矩
|
||||||
//Mat hu2 = new Mat();
|
//Mat hu2 = new Mat();
|
||||||
@ -340,119 +376,138 @@ namespace BRS.Process.A020
|
|||||||
|
|
||||||
VP.Clear();
|
VP.Clear();
|
||||||
VR.Clear();
|
VR.Clear();
|
||||||
|
|
||||||
/*************生成像素数据*********************/
|
/*************生成像素数据*********************/
|
||||||
|
|
||||||
|
for (int i = 0; i < VPList.Count; i++)
|
||||||
|
{
|
||||||
MyPoint tp;
|
MyPoint tp;
|
||||||
tp.dX = VPList[0].X;//2054;
|
tp.dX = VPList[i].X;//2054;
|
||||||
tp.dY = VPList[0].Y;// 1831;
|
tp.dY = VPList[i].Y;// 1831;
|
||||||
VP.Add(tp);
|
|
||||||
|
|
||||||
tp.dX = VPList[1].X;// 2033;
|
|
||||||
tp.dY = VPList[1].Y; //986;
|
|
||||||
VP.Add(tp);
|
|
||||||
|
|
||||||
tp.dX = VPList[2].X;//2013;
|
|
||||||
tp.dY = VPList[2].Y;//168;
|
|
||||||
VP.Add(tp);
|
|
||||||
|
|
||||||
tp.dX = VPList[3].X;// 1369;
|
|
||||||
tp.dY = VPList[3].Y; //235;
|
|
||||||
VP.Add(tp);
|
VP.Add(tp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////5-8
|
//MyPoint tp;
|
||||||
tp.dX = VPList[4].X;// 1369;
|
//tp.dX = VPList[0].X;//2054;
|
||||||
tp.dY = VPList[4].Y; //235;
|
//tp.dY = VPList[0].Y;// 1831;
|
||||||
// tp.dX = 1403;
|
//VP.Add(tp);
|
||||||
//tp.dY = 985;
|
|
||||||
VP.Add(tp);
|
|
||||||
|
|
||||||
tp.dX = VPList[5].X;// 1327;
|
//tp.dX = VPList[1].X;// 2033;
|
||||||
tp.dY = VPList[5].Y;// 1756;
|
//tp.dY = VPList[1].Y; //986;
|
||||||
VP.Add(tp);
|
//VP.Add(tp);
|
||||||
|
|
||||||
tp.dX = VPList[6].X;// 717;
|
//tp.dX = VPList[2].X;//2013;
|
||||||
tp.dY = VPList[6].Y;// 1701;
|
//tp.dY = VPList[2].Y;//168;
|
||||||
VP.Add(tp);
|
//VP.Add(tp);
|
||||||
|
|
||||||
tp.dX = VPList[7].X;// 879;
|
//tp.dX = VPList[3].X;// 1369;
|
||||||
tp.dY = VPList[7].Y;// 947;
|
//tp.dY = VPList[3].Y; //235;
|
||||||
VP.Add(tp);
|
//VP.Add(tp);
|
||||||
////
|
|
||||||
|
|
||||||
tp.dX = VPList[8].X;// 774;
|
|
||||||
tp.dY = VPList[8].Y;// 236;
|
|
||||||
VP.Add(tp);
|
|
||||||
|
|
||||||
tp.dX = VPList[9].X;// 257;
|
//////5-8
|
||||||
tp.dY = VPList[9].Y;// ;
|
//tp.dX = VPList[4].X;// 1369;
|
||||||
VP.Add(tp);
|
//tp.dY = VPList[4].Y; //235;
|
||||||
|
// // tp.dX = 1403;
|
||||||
|
// //tp.dY = 985;
|
||||||
|
//VP.Add(tp);
|
||||||
|
|
||||||
tp.dX = VPList[10].X;// 307;
|
//tp.dX = VPList[5].X;// 1327;
|
||||||
tp.dY = VPList[10].Y;// 994;
|
//tp.dY = VPList[5].Y;// 1756;
|
||||||
VP.Add(tp);
|
//VP.Add(tp);
|
||||||
|
|
||||||
tp.dX = VPList[11].X;// 303;
|
//tp.dX = VPList[6].X;// 717;
|
||||||
tp.dY = VPList[11].Y;// 1727;
|
//tp.dY = VPList[6].Y;// 1701;
|
||||||
VP.Add(tp);
|
//VP.Add(tp);
|
||||||
|
|
||||||
|
//tp.dX = VPList[7].X;// 879;
|
||||||
|
//tp.dY = VPList[7].Y;// 947;
|
||||||
|
//VP.Add(tp);
|
||||||
|
//////
|
||||||
|
|
||||||
|
//tp.dX = VPList[8].X;// 774;
|
||||||
|
//tp.dY = VPList[8].Y;// 236;
|
||||||
|
//VP.Add(tp);
|
||||||
|
|
||||||
|
//tp.dX = VPList[9].X;// 257;
|
||||||
|
//tp.dY = VPList[9].Y;// ;
|
||||||
|
//VP.Add(tp);
|
||||||
|
|
||||||
|
//tp.dX = VPList[10].X;// 307;
|
||||||
|
//tp.dY = VPList[10].Y;// 994;
|
||||||
|
//VP.Add(tp);
|
||||||
|
|
||||||
|
//tp.dX = VPList[11].X;// 303;
|
||||||
|
//tp.dY = VPList[11].Y;// 1727;
|
||||||
|
//VP.Add(tp);
|
||||||
|
|
||||||
/*************生成三维数据*********************/
|
/*************生成三维数据*********************/
|
||||||
|
|
||||||
|
for (int i = 0; i < VRList.Count; i++)
|
||||||
|
{
|
||||||
MyPoint tr;
|
MyPoint tr;
|
||||||
tr.dX = VRList[0].X + PYliangx;
|
tr.dX = VRList[i].X + PYliangx;
|
||||||
tr.dY = VRList[0].Y + PYliangy;
|
tr.dY = VRList[i].Y + PYliangy;
|
||||||
VR.Add(tr);
|
VR.Add(tr);
|
||||||
|
}
|
||||||
|
|
||||||
|
//MyPoint tr;
|
||||||
|
//tr.dX = VRList[0].X + PYliangx;
|
||||||
|
//tr.dY = VRList[0].Y + PYliangy;
|
||||||
|
//VR.Add(tr);
|
||||||
|
|
||||||
|
|
||||||
tr.dX = VRList[1].X + PYliangx;
|
//tr.dX = VRList[1].X + PYliangx;
|
||||||
tr.dY = VRList[1].Y + PYliangy;
|
//tr.dY = VRList[1].Y + PYliangy;
|
||||||
VR.Add(tr);
|
//VR.Add(tr);
|
||||||
|
|
||||||
tr.dX = VRList[2].X + PYliangx;
|
//tr.dX = VRList[2].X + PYliangx;
|
||||||
tr.dY = VRList[2].Y + PYliangy;
|
//tr.dY = VRList[2].Y + PYliangy;
|
||||||
VR.Add(tr);
|
//VR.Add(tr);
|
||||||
|
|
||||||
//////////////
|
////////////////
|
||||||
|
|
||||||
tr.dX = VRList[3].X + PYliangx;
|
//tr.dX = VRList[3].X + PYliangx;
|
||||||
tr.dY = VRList[3].Y + PYliangy;
|
//tr.dY = VRList[3].Y + PYliangy;
|
||||||
VR.Add(tr);
|
//VR.Add(tr);
|
||||||
|
|
||||||
tr.dX = VRList[4].X + PYliangx;
|
//tr.dX = VRList[4].X + PYliangx;
|
||||||
tr.dY = VRList[4].Y + PYliangy;
|
//tr.dY = VRList[4].Y + PYliangy;
|
||||||
VR.Add(tr);
|
//VR.Add(tr);
|
||||||
|
|
||||||
|
|
||||||
tr.dX = VRList[5].X + PYliangx;
|
//tr.dX = VRList[5].X + PYliangx;
|
||||||
tr.dY = VRList[5].Y + PYliangy;
|
//tr.dY = VRList[5].Y + PYliangy;
|
||||||
VR.Add(tr);
|
//VR.Add(tr);
|
||||||
|
|
||||||
|
|
||||||
//////////////7
|
////////////////7
|
||||||
tr.dX = VRList[6].X + PYliangx;
|
//tr.dX = VRList[6].X + PYliangx;
|
||||||
tr.dY = VRList[6].Y + PYliangy;
|
//tr.dY = VRList[6].Y + PYliangy;
|
||||||
VR.Add(tr);
|
//VR.Add(tr);
|
||||||
|
|
||||||
tr.dX = VRList[7].X + PYliangx;
|
//tr.dX = VRList[7].X + PYliangx;
|
||||||
tr.dY = VRList[7].Y + PYliangy;
|
//tr.dY = VRList[7].Y + PYliangy;
|
||||||
VR.Add(tr);
|
//VR.Add(tr);
|
||||||
|
|
||||||
tr.dX = VRList[8].X + PYliangx;
|
//tr.dX = VRList[8].X + PYliangx;
|
||||||
tr.dY = VRList[8].Y + PYliangy;
|
//tr.dY = VRList[8].Y + PYliangy;
|
||||||
VR.Add(tr);
|
//VR.Add(tr);
|
||||||
|
|
||||||
//////////////
|
////////////////
|
||||||
|
|
||||||
tr.dX = VRList[9].X + PYliangx;
|
//tr.dX = VRList[9].X + PYliangx;
|
||||||
tr.dY = VRList[9].Y + PYliangy;
|
//tr.dY = VRList[9].Y + PYliangy;
|
||||||
VR.Add(tr);
|
//VR.Add(tr);
|
||||||
|
|
||||||
tr.dX = VRList[10].X + PYliangx;
|
//tr.dX = VRList[10].X + PYliangx;
|
||||||
tr.dY = VRList[10].Y + PYliangy;
|
//tr.dY = VRList[10].Y + PYliangy;
|
||||||
VR.Add(tr);
|
//VR.Add(tr);
|
||||||
|
|
||||||
tr.dX = VRList[11].X + PYliangx;
|
//tr.dX = VRList[11].X + PYliangx;
|
||||||
tr.dY = VRList[11].Y + PYliangy;
|
//tr.dY = VRList[11].Y + PYliangy;
|
||||||
VR.Add(tr);
|
//VR.Add(tr);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -473,14 +528,16 @@ namespace BRS.Process.A020
|
|||||||
Console.WriteLine(DateTime.Now + "==========配置=================" + stopWatch2.ElapsedMilliseconds + "===========================");
|
Console.WriteLine(DateTime.Now + "==========配置=================" + stopWatch2.ElapsedMilliseconds + "===========================");
|
||||||
|
|
||||||
//MyPoint ssw = new MyPoint();
|
//MyPoint ssw = new MyPoint();
|
||||||
Mat Image = Cv2.ImRead(@"D:\MelsecPLCReadWrite\Bk\Image\1.png");
|
//Mat Image = Cv2.ImRead(@"D:\MelsecPLCReadWrite\Bk\Image\1.png");
|
||||||
List<MyPoint> resultPoint = new List<MyPoint>();
|
List<MyPoint> resultPoint = new List<MyPoint>();
|
||||||
|
#if false
|
||||||
Mat _mat = dd.Clone();
|
Mat _mat = dd.Clone();
|
||||||
string ss = "D:\\QT\\" + DateTime.Now.ToString("HHmmssfff") + ".jpg";
|
string ss = "D:\\QT\\" + DateTime.Now.ToString("HHmmssfff") + ".jpg";
|
||||||
Cv2.ImWrite(ss, _mat);
|
Cv2.ImWrite(ss, _mat);
|
||||||
|
#endif
|
||||||
|
Mat _mat = dd.Clone();
|
||||||
|
|
||||||
GetScrew(Image, resultPoint);
|
GetScrew(_mat, resultPoint);
|
||||||
|
|
||||||
MyPoint ssw3 = resultPoint[0];
|
MyPoint ssw3 = resultPoint[0];
|
||||||
|
|
||||||
@ -534,6 +591,9 @@ namespace BRS.Process.A020
|
|||||||
var MelsecPLC = DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase;
|
var MelsecPLC = DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase;
|
||||||
var KawasakiRobot = DeviceCollection.Find(d => d is KawasakiTCPSeverRobotDriver) as KawasakiTCPSeverRobotDriver;
|
var KawasakiRobot = DeviceCollection.Find(d => d is KawasakiTCPSeverRobotDriver) as KawasakiTCPSeverRobotDriver;
|
||||||
|
|
||||||
|
|
||||||
|
float NJZt = AModeTypeRun.NIJ_DisD;
|
||||||
|
|
||||||
StrRobotPoint strPointInitA;//示教点位
|
StrRobotPoint strPointInitA;//示教点位
|
||||||
strPointInitA.X = 847.462F;
|
strPointInitA.X = 847.462F;
|
||||||
strPointInitA.Y = 891.623F;
|
strPointInitA.Y = 891.623F;
|
||||||
@ -543,7 +603,7 @@ namespace BRS.Process.A020
|
|||||||
strPointInitA.C = 90F;
|
strPointInitA.C = 90F;
|
||||||
|
|
||||||
RobotPoint robotInitPoint = KawasakiRobot.IIConfig.RobotInitPosition;//机械臂初始点位
|
RobotPoint robotInitPoint = KawasakiRobot.IIConfig.RobotInitPosition;//机械臂初始点位
|
||||||
|
StrRobotPoint initPoint = ClassChangeStruct(robotInitPoint);
|
||||||
#region 驱动委托
|
#region 驱动委托
|
||||||
if (KawasakiRobot != null)
|
if (KawasakiRobot != null)
|
||||||
{
|
{
|
||||||
@ -559,8 +619,9 @@ namespace BRS.Process.A020
|
|||||||
MachineState = MachineState.Running;
|
MachineState = MachineState.Running;
|
||||||
ProcessStatus = ProcessStatus.Init;
|
ProcessStatus = ProcessStatus.Init;
|
||||||
RobotsStatus = RobotsStatus.Release;
|
RobotsStatus = RobotsStatus.Release;
|
||||||
KawasakiRobotInit(KawasakiRobot);//机械臂移动到初始位置
|
KawasakiRobotMove(KawasakiRobot, initPoint);
|
||||||
OpenCam1();
|
//KawasakiRobotInit(KawasakiRobot);//机械臂移动到初始位置
|
||||||
|
//OpenCam1();
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
@ -621,13 +682,13 @@ namespace BRS.Process.A020
|
|||||||
KawasakiRobot.SendMessage(PointInitMove);
|
KawasakiRobot.SendMessage(PointInitMove);
|
||||||
LogAsync(DateTime.Now, LogLevel.Assist, $"机械臂A移动到示教点");
|
LogAsync(DateTime.Now, LogLevel.Assist, $"机械臂A移动到示教点");
|
||||||
RobotsStatus = RobotsStatus.Runing;
|
RobotsStatus = RobotsStatus.Runing;
|
||||||
DownCirce = DownCirce.DownCirce;//标志机械臂的运动状态
|
//DownCirce = DownCirce.DownCirce;//标志机械臂的运动状态
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (DownCirce == DownCirce.DownCirceRuning)
|
if (DownCirce == DownCirce.DownCirceRuning)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
Thread.Sleep(10);
|
Thread.Sleep(20);
|
||||||
}
|
}
|
||||||
ProcessStatus = ProcessStatus.OpenLight;
|
ProcessStatus = ProcessStatus.OpenLight;
|
||||||
//KawasakiRobotInit(KawasakiRobot);
|
//KawasakiRobotInit(KawasakiRobot);
|
||||||
@ -644,18 +705,20 @@ namespace BRS.Process.A020
|
|||||||
//JYDAMDriver1.WriteStrs(SerialOpenLight);
|
//JYDAMDriver1.WriteStrs(SerialOpenLight);
|
||||||
|
|
||||||
#region 拍摄图片 取图进行视觉定位
|
#region 拍摄图片 取图进行视觉定位
|
||||||
SoftTrigger1();
|
//SoftTrigger1();
|
||||||
Thread.Sleep(200);
|
Thread.Sleep(200);
|
||||||
while (CamA == true)
|
while (CamA == true)
|
||||||
{
|
{
|
||||||
//拍照视觉定位
|
//拍照视觉定位
|
||||||
OnBitmapChanged?.Invoke(1, Bit_Image);
|
//OnBitmapChanged?.Invoke(1, Bit_Image);
|
||||||
|
Mat img = Cv2.ImRead(@"D:\testData\ShaftP\173648283.jpg");
|
||||||
|
Mat Mat_CamA = img.Clone();
|
||||||
OnCameraImageOutput(ref sswF, ref Mat_CamA, 1);
|
OnCameraImageOutput(ref sswF, ref Mat_CamA, 1);
|
||||||
stopWatch.Stop();
|
stopWatch.Stop();
|
||||||
Console.WriteLine(DateTime.Now + "=========拍照==================" + stopWatch.ElapsedMilliseconds + "===========================");
|
Console.WriteLine(DateTime.Now + "=========拍照==================" + stopWatch.ElapsedMilliseconds + "===========================");
|
||||||
CamA = false;
|
CamA = false;
|
||||||
}
|
}
|
||||||
ProcessStatus = ProcessStatus.CVLocation;
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -692,7 +755,7 @@ namespace BRS.Process.A020
|
|||||||
strPointInitA1 = strPointInitA;
|
strPointInitA1 = strPointInitA;
|
||||||
StrRobotPoint strPointInitA2 = new StrRobotPoint();
|
StrRobotPoint strPointInitA2 = new StrRobotPoint();
|
||||||
strPointInitA2 = strPointInitA;
|
strPointInitA2 = strPointInitA;
|
||||||
strPointInitA2.Z += Distance_DisD;//XYZ是毫米
|
strPointInitA2.Z += NJZt;//XYZ是毫米
|
||||||
_strRobotPointAs.Add(strPointInitA1);
|
_strRobotPointAs.Add(strPointInitA1);
|
||||||
_strRobotPointAs.Add(strPointInitA2);
|
_strRobotPointAs.Add(strPointInitA2);
|
||||||
//KawasakiRobotMoves(KawasakiRobot, _strRobotPointAs, false);
|
//KawasakiRobotMoves(KawasakiRobot, _strRobotPointAs, false);
|
||||||
@ -904,7 +967,7 @@ namespace BRS.Process.A020
|
|||||||
case ProcessStatus.UpShaft:
|
case ProcessStatus.UpShaft:
|
||||||
{
|
{
|
||||||
RobotPoint robotInitPoint1 = KawasakiRobot.IIConfig.RobotInitPosition;//机器人初始点
|
RobotPoint robotInitPoint1 = KawasakiRobot.IIConfig.RobotInitPosition;//机器人初始点
|
||||||
StrRobotPoint initPoint = ClassChangeStruct(robotInitPoint);
|
StrRobotPoint initPoint1 = ClassChangeStruct(robotInitPoint);
|
||||||
|
|
||||||
List<StrRobotPoint> _strRobotPointAup = new List<StrRobotPoint>();
|
List<StrRobotPoint> _strRobotPointAup = new List<StrRobotPoint>();
|
||||||
StrRobotPoint strPointInitA3 = new StrRobotPoint();
|
StrRobotPoint strPointInitA3 = new StrRobotPoint();
|
||||||
@ -912,8 +975,8 @@ namespace BRS.Process.A020
|
|||||||
StrRobotPoint strPointInitA4 = new StrRobotPoint();
|
StrRobotPoint strPointInitA4 = new StrRobotPoint();
|
||||||
strPointInitA4 = strPointInitA;
|
strPointInitA4 = strPointInitA;
|
||||||
StrRobotPoint strPointInitA5 = new StrRobotPoint();
|
StrRobotPoint strPointInitA5 = new StrRobotPoint();
|
||||||
strPointInitA5 = initPoint;
|
strPointInitA5 = initPoint1;
|
||||||
strPointInitA4.Z -= Distance_DisD;//XYZ是毫米
|
strPointInitA4.Z -= NJZt;//XYZ是毫米
|
||||||
_strRobotPointAup.Add(strPointInitA4);
|
_strRobotPointAup.Add(strPointInitA4);
|
||||||
_strRobotPointAup.Add(strPointInitA3);
|
_strRobotPointAup.Add(strPointInitA3);
|
||||||
_strRobotPointAup.Add(strPointInitA5);
|
_strRobotPointAup.Add(strPointInitA5);
|
||||||
@ -1479,6 +1542,7 @@ namespace BRS.Process.A020
|
|||||||
KawasakiRobotStatus = KawasakiRobotStatus.Runing;
|
KawasakiRobotStatus = KawasakiRobotStatus.Runing;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
KawasakiRobotStatus = KawasakiRobotStatus.Stoped;
|
||||||
if (KawasakiRobotStatus == KawasakiRobotStatus.Stoped)
|
if (KawasakiRobotStatus == KawasakiRobotStatus.Stoped)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
|
@ -368,11 +368,11 @@ namespace BRS.Process.A020
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region 测距信息正常则流程打开光源 若不正常继续移动机械臂直到正常
|
#region 测距信息正常则流程打开光源 若不正常继续移动机械臂直到正常
|
||||||
if (ProcessStatus == ProcessStatus.Measure && RobotsStatus == RobotsStatus.Runing && msg == "wanbi")
|
if (ProcessStatus == ProcessStatus.OpenLight && RobotsStatus == RobotsStatus)
|
||||||
{
|
{
|
||||||
msg = string.Empty;
|
msg = string.Empty;
|
||||||
DownCirce = DownCirce.DownCirceRuning;
|
DownCirce = DownCirce.DownCirceRuning;
|
||||||
ProcessStatus = ProcessStatus.OpenLight;
|
|
||||||
RobotsStatus = RobotsStatus.Release;
|
RobotsStatus = RobotsStatus.Release;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -65,7 +65,7 @@ namespace BRS.Process.A020.UI
|
|||||||
//ProcessA020.OnBitmapChanged -= BitMapTest;
|
//ProcessA020.OnBitmapChanged -= BitMapTest;
|
||||||
//ProcessA020.OnBitmapChanged += BitMapTest;
|
//ProcessA020.OnBitmapChanged += BitMapTest;
|
||||||
pLCBase = ProcessA020.DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase;
|
pLCBase = ProcessA020.DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase;
|
||||||
TcpListerWrapBase1 = ProcessA020.DeviceCollection.Find(d => d is TCPSeverBase && d.InitialConfig.Name == "123") as TCPSeverBase;
|
TcpListerWrapBase1 = ProcessA020.DeviceCollection.Find(d => d is TCPSeverBase && d.InitialConfig.Name == "KawasakiRobot") as TCPSeverBase;
|
||||||
if (TcpListerWrapBase1 != null)
|
if (TcpListerWrapBase1 != null)
|
||||||
{
|
{
|
||||||
TcpListerWrapBase1.OnTcpDataReceived -= NbtRobotDriver_OnDataReceived;
|
TcpListerWrapBase1.OnTcpDataReceived -= NbtRobotDriver_OnDataReceived;
|
||||||
@ -87,7 +87,10 @@ namespace BRS.Process.A020.UI
|
|||||||
private void NbtRobotDriver_OnDataReceived(byte[] obj)
|
private void NbtRobotDriver_OnDataReceived(byte[] obj)
|
||||||
{
|
{
|
||||||
string msg = string.Empty;
|
string msg = string.Empty;
|
||||||
|
|
||||||
|
RobotAStatus.BackColor = Color.Green;
|
||||||
msg = Encoding.Default.GetString(obj);
|
msg = Encoding.Default.GetString(obj);
|
||||||
|
|
||||||
Message1 = msg;
|
Message1 = msg;
|
||||||
//}
|
//}
|
||||||
//else if (rbHexData.Checked)
|
//else if (rbHexData.Checked)
|
||||||
@ -579,6 +582,7 @@ namespace BRS.Process.A020.UI
|
|||||||
if (isStart)
|
if (isStart)
|
||||||
{
|
{
|
||||||
ProcessOperation(true);
|
ProcessOperation(true);
|
||||||
|
//RobotAStatus.BackColor = Color.Green;
|
||||||
//ProcessOperation(true);
|
//ProcessOperation(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user