|
@@ -312,6 +312,9 @@ namespace TeamAAS_VP.Services
|
|
|
calibrationInfo.Tool.X = toolCoord.X;
|
|
calibrationInfo.Tool.X = toolCoord.X;
|
|
|
calibrationInfo.Tool.Y = toolCoord.Y;
|
|
calibrationInfo.Tool.Y = toolCoord.Y;
|
|
|
|
|
|
|
|
|
|
+ //移动机器人至中心位置
|
|
|
|
|
+ await robot.CalibMotionAsync(calibrationInfo.CenterPoint, calibrationInfo.CenterPoint.Z);
|
|
|
|
|
+
|
|
|
return (true, RobotCameraRotationMatrix, calibrationInfo.Tool.X, calibrationInfo.Tool.Y, pixelScaleX, pixelScaleY);
|
|
return (true, RobotCameraRotationMatrix, calibrationInfo.Tool.X, calibrationInfo.Tool.Y, pixelScaleX, pixelScaleY);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -417,6 +420,9 @@ namespace TeamAAS_VP.Services
|
|
|
calibrationInfo.Tool.X = toolCoord.X;
|
|
calibrationInfo.Tool.X = toolCoord.X;
|
|
|
calibrationInfo.Tool.Y = toolCoord.Y;
|
|
calibrationInfo.Tool.Y = toolCoord.Y;
|
|
|
|
|
|
|
|
|
|
+ //移动机器人至中心位置
|
|
|
|
|
+ await robot.CalibMotionAsync(calibrationInfo.CenterPoint, calibrationInfo.CenterPoint.Z);
|
|
|
|
|
+
|
|
|
return (true, RobotCameraRotationMatrix, calibrationInfo.Tool.X, calibrationInfo.Tool.Y, pixelScaleX, pixelScaleY);
|
|
return (true, RobotCameraRotationMatrix, calibrationInfo.Tool.X, calibrationInfo.Tool.Y, pixelScaleX, pixelScaleY);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -782,36 +788,36 @@ namespace TeamAAS_VP.Services
|
|
|
await robot.CalibParameAsync(calibrationInfo.Pick, calibrationInfo.Speed, calibrationInfo.Accel, calibrationInfo.Power, calibrationInfo.WaitSuction, calibrationInfo.WaitBlow);
|
|
await robot.CalibParameAsync(calibrationInfo.Pick, calibrationInfo.Speed, calibrationInfo.Accel, calibrationInfo.Power, calibrationInfo.WaitSuction, calibrationInfo.WaitBlow);
|
|
|
|
|
|
|
|
var P0 = Vector<double>.Build.Dense(new double[] { calibrationInfo.CenterPoint.X, calibrationInfo.CenterPoint.Y });
|
|
var P0 = Vector<double>.Build.Dense(new double[] { calibrationInfo.CenterPoint.X, calibrationInfo.CenterPoint.Y });
|
|
|
- if (robot.Brand == Enums.RobotBrand.XYZ_Platform)
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- //移动机器人至中心位置
|
|
|
|
|
- await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
|
|
|
|
|
- if (cancellationToken.IsCancellationRequested)
|
|
|
|
|
- {
|
|
|
|
|
- return (false, null, null, null);
|
|
|
|
|
- }
|
|
|
|
|
- //计算相机与机器人坐标系的旋转矩阵
|
|
|
|
|
- var robotCameraRotationMatrix = await AutoIdentifyRobotCameraRotationMatrix(calibrationInfo, robot, cancellationToken);
|
|
|
|
|
- if (!robotCameraRotationMatrix.IsSuccess)
|
|
|
|
|
- {
|
|
|
|
|
- return (false, null, null, null);
|
|
|
|
|
- }
|
|
|
|
|
- //自动移动机器人至图像中心点位置
|
|
|
|
|
- var autoMoveResult = await AutoMoveRobotToImageCenter(robot, robotCameraRotationMatrix.RotationMatrix, robotCameraRotationMatrix.PixelScaleX, robotCameraRotationMatrix.PixelScaleY, cancellationToken);
|
|
|
|
|
- if (!autoMoveResult.IsSuccess)
|
|
|
|
|
- {
|
|
|
|
|
- return (false, null, null, null);
|
|
|
|
|
- }
|
|
|
|
|
- calibrationInfo.CenterPoint.X = (float)autoMoveResult.X;
|
|
|
|
|
- calibrationInfo.CenterPoint.Y = (float)autoMoveResult.Y;
|
|
|
|
|
- if (calibrationInfo.CameraMount != Enums.CameraMount.MobileDown_XYPlatform)
|
|
|
|
|
- {
|
|
|
|
|
- calibrationInfo.MarkPoint = calibrationInfo.CenterPoint.Clone();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //if (robot.Brand == Enums.RobotBrand.XYZ_Platform)
|
|
|
|
|
+ //{
|
|
|
|
|
+
|
|
|
|
|
+ // //移动机器人至中心位置
|
|
|
|
|
+ // await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
|
|
|
|
|
+ // if (cancellationToken.IsCancellationRequested)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // return (false, null, null, null);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // //计算相机与机器人坐标系的旋转矩阵
|
|
|
|
|
+ // var robotCameraRotationMatrix = await AutoIdentifyRobotCameraRotationMatrix(calibrationInfo, robot, cancellationToken);
|
|
|
|
|
+ // if (!robotCameraRotationMatrix.IsSuccess)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // return (false, null, null, null);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // //自动移动机器人至图像中心点位置
|
|
|
|
|
+ // var autoMoveResult = await AutoMoveRobotToImageCenter(robot, robotCameraRotationMatrix.RotationMatrix, robotCameraRotationMatrix.PixelScaleX, robotCameraRotationMatrix.PixelScaleY, cancellationToken);
|
|
|
|
|
+ // if (!autoMoveResult.IsSuccess)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // return (false, null, null, null);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // calibrationInfo.CenterPoint.X = (float)autoMoveResult.X;
|
|
|
|
|
+ // calibrationInfo.CenterPoint.Y = (float)autoMoveResult.Y;
|
|
|
|
|
+ // if (calibrationInfo.CameraMount != Enums.CameraMount.MobileDown_XYPlatform)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // calibrationInfo.MarkPoint = calibrationInfo.CenterPoint.Clone();
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
- calibrationInfo.RobotCameraRotationMatrix = robotCameraRotationMatrix.RotationMatrix.ToArray();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // calibrationInfo.RobotCameraRotationMatrix = robotCameraRotationMatrix.RotationMatrix.ToArray();
|
|
|
|
|
+ //}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// 机器人与相机之间的旋转矩阵
|
|
/// 机器人与相机之间的旋转矩阵
|
|
@@ -1071,14 +1077,14 @@ namespace TeamAAS_VP.Services
|
|
|
matRobot.Set<double>(i, 0, calibrationInfo.MarkPoint.X - ox);
|
|
matRobot.Set<double>(i, 0, calibrationInfo.MarkPoint.X - ox);
|
|
|
matRobot.Set<double>(i, 1, calibrationInfo.MarkPoint.Y - oy);
|
|
matRobot.Set<double>(i, 1, calibrationInfo.MarkPoint.Y - oy);
|
|
|
}
|
|
}
|
|
|
- else if (calibrationInfo.CameraMount == Enums.CameraMount.MobileDown_XYPlatform)
|
|
|
|
|
- {
|
|
|
|
|
- //计算每个点相对于第一个点移动的偏移量,将这个偏移量
|
|
|
|
|
- double ox = rPoints[i].X - rPoints[0].X;
|
|
|
|
|
- double oy = rPoints[i].Y - rPoints[0].Y;
|
|
|
|
|
- matRobot.Set<double>(i, 0, calibrationInfo.MarkPoint.X - ox);
|
|
|
|
|
- matRobot.Set<double>(i, 1, calibrationInfo.MarkPoint.Y - oy);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //else if (calibrationInfo.CameraMount == Enums.CameraMount.MobileDown_XYPlatform)
|
|
|
|
|
+ //{
|
|
|
|
|
+ // //计算每个点相对于第一个点移动的偏移量,将这个偏移量
|
|
|
|
|
+ // double ox = rPoints[i].X - rPoints[0].X;
|
|
|
|
|
+ // double oy = rPoints[i].Y - rPoints[0].Y;
|
|
|
|
|
+ // matRobot.Set<double>(i, 0, calibrationInfo.MarkPoint.X - ox);
|
|
|
|
|
+ // matRobot.Set<double>(i, 1, calibrationInfo.MarkPoint.Y - oy);
|
|
|
|
|
+ //}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
//将tool 0下的坐标转换成Tool n下的坐标
|
|
//将tool 0下的坐标转换成Tool n下的坐标
|
|
@@ -1131,13 +1137,13 @@ namespace TeamAAS_VP.Services
|
|
|
differenceX.Add((calibrationInfo.MarkPoint.X - ox) - (matrix * pixel)[0]);
|
|
differenceX.Add((calibrationInfo.MarkPoint.X - ox) - (matrix * pixel)[0]);
|
|
|
differenceY.Add((calibrationInfo.MarkPoint.Y - oy) - (matrix * pixel)[1]);
|
|
differenceY.Add((calibrationInfo.MarkPoint.Y - oy) - (matrix * pixel)[1]);
|
|
|
}
|
|
}
|
|
|
- else if (calibrationInfo.CameraMount == Enums.CameraMount.MobileDown_XYPlatform)
|
|
|
|
|
- {
|
|
|
|
|
- double ox = rPoints[i].X - rPoints[0].X;
|
|
|
|
|
- double oy = rPoints[i].Y - rPoints[0].Y;
|
|
|
|
|
- differenceX.Add((calibrationInfo.MarkPoint.X - ox) - (matrix * pixel)[0]);
|
|
|
|
|
- differenceY.Add((calibrationInfo.MarkPoint.Y - oy) - (matrix * pixel)[1]);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //else if (calibrationInfo.CameraMount == Enums.CameraMount.MobileDown_XYPlatform)
|
|
|
|
|
+ //{
|
|
|
|
|
+ // double ox = rPoints[i].X - rPoints[0].X;
|
|
|
|
|
+ // double oy = rPoints[i].Y - rPoints[0].Y;
|
|
|
|
|
+ // differenceX.Add((calibrationInfo.MarkPoint.X - ox) - (matrix * pixel)[0]);
|
|
|
|
|
+ // differenceY.Add((calibrationInfo.MarkPoint.Y - oy) - (matrix * pixel)[1]);
|
|
|
|
|
+ //}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
//将tool 0下的坐标转换成Tool n下的坐标
|
|
//将tool 0下的坐标转换成Tool n下的坐标
|
|
@@ -1380,36 +1386,36 @@ namespace TeamAAS_VP.Services
|
|
|
differenceX.Add(cc[0] - calibrationInfo.MarkPoint.X);
|
|
differenceX.Add(cc[0] - calibrationInfo.MarkPoint.X);
|
|
|
differenceY.Add(cc[1] - calibrationInfo.MarkPoint.Y);
|
|
differenceY.Add(cc[1] - calibrationInfo.MarkPoint.Y);
|
|
|
}
|
|
}
|
|
|
- else if (calibrationInfo.CameraMount == Enums.CameraMount.MobileDown_XYPlatform)
|
|
|
|
|
- {
|
|
|
|
|
- //像素直接转换成mm时的点位
|
|
|
|
|
- double Robot_X, Robot_Y;
|
|
|
|
|
- Robot_X = TestPos[i][0];
|
|
|
|
|
- Robot_Y = TestPos[i][1];
|
|
|
|
|
-
|
|
|
|
|
- //机器人当前TOOL 0下的坐标
|
|
|
|
|
- double curpos_x = 0, curpos_y = 0, curpos_u = 0;
|
|
|
|
|
- curpos_x = rPoints[i].X;
|
|
|
|
|
- curpos_y = rPoints[i].Y;
|
|
|
|
|
- curpos_u = rPoints[i].U;
|
|
|
|
|
-
|
|
|
|
|
- //得到旋转矩阵
|
|
|
|
|
- double angle = Math.PI * (curpos_u - calibrationInfo.MarkPoint.U) / 180;
|
|
|
|
|
- // 创建T矩阵
|
|
|
|
|
- Matrix<double> rotationMatrix = Matrix<double>.Build.DenseOfArray(new double[,]
|
|
|
|
|
- {
|
|
|
|
|
- { Math.Cos(angle), -Math.Sin(angle) },
|
|
|
|
|
- { Math.Sin(angle), Math.Cos(angle) }
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- Vector<double> p3 = Vector<double>.Build.Dense(new double[] { Robot_X - calibrationInfo.CalibPoints[0].Robot.X, Robot_Y - calibrationInfo.CalibPoints[0].Robot.Y });
|
|
|
|
|
- Vector<double> phere = Vector<double>.Build.Dense(new double[] { curpos_x, curpos_y });
|
|
|
|
|
-
|
|
|
|
|
- var cc = rotationMatrix * p3 + phere;
|
|
|
|
|
-
|
|
|
|
|
- differenceX.Add(cc[0] - calibrationInfo.MarkPoint.X);
|
|
|
|
|
- differenceY.Add(cc[1] - calibrationInfo.MarkPoint.Y);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //else if (calibrationInfo.CameraMount == Enums.CameraMount.MobileDown_XYPlatform)
|
|
|
|
|
+ //{
|
|
|
|
|
+ // //像素直接转换成mm时的点位
|
|
|
|
|
+ // double Robot_X, Robot_Y;
|
|
|
|
|
+ // Robot_X = TestPos[i][0];
|
|
|
|
|
+ // Robot_Y = TestPos[i][1];
|
|
|
|
|
+
|
|
|
|
|
+ // //机器人当前TOOL 0下的坐标
|
|
|
|
|
+ // double curpos_x = 0, curpos_y = 0, curpos_u = 0;
|
|
|
|
|
+ // curpos_x = rPoints[i].X;
|
|
|
|
|
+ // curpos_y = rPoints[i].Y;
|
|
|
|
|
+ // curpos_u = rPoints[i].U;
|
|
|
|
|
+
|
|
|
|
|
+ // //得到旋转矩阵
|
|
|
|
|
+ // double angle = Math.PI * (curpos_u - calibrationInfo.MarkPoint.U) / 180;
|
|
|
|
|
+ // // 创建T矩阵
|
|
|
|
|
+ // Matrix<double> rotationMatrix = Matrix<double>.Build.DenseOfArray(new double[,]
|
|
|
|
|
+ // {
|
|
|
|
|
+ // { Math.Cos(angle), -Math.Sin(angle) },
|
|
|
|
|
+ // { Math.Sin(angle), Math.Cos(angle) }
|
|
|
|
|
+ // });
|
|
|
|
|
+
|
|
|
|
|
+ // Vector<double> p3 = Vector<double>.Build.Dense(new double[] { Robot_X - calibrationInfo.CalibPoints[0].Robot.X, Robot_Y - calibrationInfo.CalibPoints[0].Robot.Y });
|
|
|
|
|
+ // Vector<double> phere = Vector<double>.Build.Dense(new double[] { curpos_x, curpos_y });
|
|
|
|
|
+
|
|
|
|
|
+ // var cc = rotationMatrix * p3 + phere;
|
|
|
|
|
+
|
|
|
|
|
+ // differenceX.Add(cc[0] - calibrationInfo.MarkPoint.X);
|
|
|
|
|
+ // differenceY.Add(cc[1] - calibrationInfo.MarkPoint.Y);
|
|
|
|
|
+ //}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
//将tool 0下的坐标转换成Tool n下的坐标
|
|
//将tool 0下的坐标转换成Tool n下的坐标
|