|
|
@@ -3,6 +3,7 @@ using MahApps.Metro.Controls;
|
|
|
using MaterialDesignThemes.Wpf;
|
|
|
using MathNet.Numerics.LinearAlgebra;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
+using OpenCvSharp.Flann;
|
|
|
using Prism.Commands;
|
|
|
using Prism.Events;
|
|
|
using Prism.Ioc;
|
|
|
@@ -586,20 +587,36 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- //Robot.Timeout = 6000000;
|
|
|
- switch (motionCmd)
|
|
|
+ if (SelectedIndex == 1)
|
|
|
{
|
|
|
- case MotionCommand.Go:
|
|
|
- await Robot.GoAsync(point);
|
|
|
- break;
|
|
|
- case MotionCommand.Jump:
|
|
|
- await Robot.JumpAsync(point, 0);
|
|
|
- break;
|
|
|
- case MotionCommand.Move:
|
|
|
- await Robot.MoveAsync(point);
|
|
|
- break;
|
|
|
+ var curpos = await Robot.GetRobotPosAsync();
|
|
|
+ var addpos = await Robot.GetAdditionalAxisCurrentPosAsync(Robot.AdditionalAxisList[0].Name);
|
|
|
+ curpos.Z = 0;
|
|
|
+ await Robot.AdditionalAxisMoveAsync(Robot.AdditionalAxisList[0].Name, PickP1.Z_Position_Stop);
|
|
|
+ curpos.X = SelectedPoint.X_Position;
|
|
|
+ curpos.Y = SelectedPoint.Y_Position;
|
|
|
+ curpos.Z = SelectedPoint.Z_Position_Start;
|
|
|
+ curpos.U = SelectedPoint.U_Position;
|
|
|
+ await Robot.CalibMotionAsync(curpos, 0);
|
|
|
}
|
|
|
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.完成}!", Duration = 0.4 });
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //Robot.Timeout = 6000000;
|
|
|
+ switch (motionCmd)
|
|
|
+ {
|
|
|
+ case MotionCommand.Go:
|
|
|
+ await Robot.GoAsync(point);
|
|
|
+ break;
|
|
|
+ case MotionCommand.Jump:
|
|
|
+ await Robot.JumpAsync(point, 0);
|
|
|
+ break;
|
|
|
+ case MotionCommand.Move:
|
|
|
+ await Robot.MoveAsync(point);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.完成}!", Duration = 0.4 });
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
@@ -649,8 +666,21 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
}
|
|
|
else if (SelectedIndex == 1)
|
|
|
{
|
|
|
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "当前模式不允许直接示教取料点!", Duration = 1 });
|
|
|
- return;
|
|
|
+ //弹窗用户是否确认要示教该点位
|
|
|
+ if (MessageBox.Show($"确认要示教点位 {SelectedPoint.Number} 吗?", "示教点位", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ var curpos = await Robot.GetRobotPosAsync();
|
|
|
+ var addpos = await Robot.GetAdditionalAxisCurrentPosAsync(Robot.AdditionalAxisList[0].Name);
|
|
|
+ SelectedPoint.X_Position = curpos.X;
|
|
|
+ SelectedPoint.Y_Position = curpos.Y;
|
|
|
+ SelectedPoint.Z_Position_Start = curpos.Z;
|
|
|
+ SelectedPoint.U_Position = curpos.U;
|
|
|
+ SelectedPoint.R_Position = curpos.V;
|
|
|
+ SelectedPoint.Z_Position_Stop = addpos;
|
|
|
+ _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.完成}!", Duration = 0.4 });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -1280,29 +1310,13 @@ namespace TeamAAS_VP.ViewModels.Product
|
|
|
await task;
|
|
|
return;
|
|
|
}
|
|
|
- //获取移动向下相机2的流程
|
|
|
- var process2 = _productService.GetCurrentProductProcedureModelById(SelectProduct.MoveDownCamera2LockPhotoProcedureId);
|
|
|
- if (process2 == null)
|
|
|
- {
|
|
|
- _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"移动向下相机2视觉流程,流程ID:{SelectProduct.MoveDownCamera2LockPhotoProcedureId} 未找到!", Duration = 1 });
|
|
|
- if (DialogHost.IsDialogOpen("RootDialog"))
|
|
|
- {
|
|
|
- DialogHost.Close("RootDialog");
|
|
|
- }
|
|
|
- await task;
|
|
|
- return;
|
|
|
- }
|
|
|
// 执行视觉任务
|
|
|
var _cts = new CancellationTokenSource();
|
|
|
- var task1 = _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, new double[] { rpoint.X, rpoint.Y, rpoint.U }, _cts.Token);
|
|
|
- var task2 = _remoteCommandService.ExecutePhotoGetSinglePoint(process2, null, new double[] { rpoint.X, rpoint.Y, rpoint.U }, _cts.Token);
|
|
|
- var visionResults = await Task.WhenAll(task1, task2);
|
|
|
- if (visionResults[0].IsSucceed && visionResults[1].IsSucceed)
|
|
|
+ var visionResult =await _remoteCommandService.ExecutePhotoGetSinglePoint(process1, null, new double[] { rpoint.X, rpoint.Y, rpoint.U }, _cts.Token);
|
|
|
+ if (visionResult.IsSucceed)
|
|
|
{
|
|
|
- float centerX = (float)(visionResults[0].X + visionResults[1].X) / 2;
|
|
|
- float centerY = (float)(visionResults[0].Y + visionResults[1].Y) / 2;
|
|
|
- _MoveCameraTempletAngle = Common.CalculateAngleBetweenPointsDegrees(new PointF((float)visionResults[0].X, (float)visionResults[0].Y), new PointF((float)visionResults[1].X, (float)visionResults[1].Y));
|
|
|
- _PutPoint = new PointF(centerX, centerY);
|
|
|
+ _MoveCameraTempletAngle = visionResult.U;
|
|
|
+ _PutPoint = new PointF((float)visionResult.X, (float)visionResult.Y);
|
|
|
|
|
|
if (DialogHost.IsDialogOpen("RootDialog"))
|
|
|
{
|