Jelajahi Sumber

修复错误

徐孝锋 8 bulan lalu
induk
melakukan
c443309161

+ 3 - 0
TeamAAS-VM/Core/Robots/XYZU_Robot.cs

@@ -214,6 +214,7 @@ namespace TeamAAS_VP.Core.Robots
         {
             if (Plc.IsConnected)
             {
+                StopMove();
                 ConnectedEvent?.Invoke(Id, this, null);
             }
         }
@@ -222,6 +223,7 @@ namespace TeamAAS_VP.Core.Robots
         {
             if (Plc.IsConnected)
             {
+                StopMove();
                 ConnectedEvent?.Invoke(Id, this, null);
             }
             return Task.CompletedTask;
@@ -481,6 +483,7 @@ namespace TeamAAS_VP.Core.Robots
             try
             {
                 CanExecute = false;
+                Motor(true);
                 Dictionary<string, object> keyValues = new Dictionary<string, object>();
 
                 // 1. 复位所有轴的开始移动命令

+ 12 - 11
TeamAAS-VM/ViewModels/Product/AutoCorrectLockPointViewModel.cs

@@ -127,6 +127,7 @@ namespace TeamAAS_VP.ViewModels.Product
             IsExecuting= true;
             try
             {
+                
                 if (Robot == null || !Robot.IsConnected)
                 {
                     _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "机器人未连接,无法执行取料拍照点位矫正!", Duration = 1 });
@@ -180,7 +181,7 @@ namespace TeamAAS_VP.ViewModels.Product
                     return;
                 }
 
-
+                _cts = new CancellationTokenSource();
                 //移动机器人至拍照点位,拍照
                 var rpoint = new RPoint()
                 {
@@ -206,11 +207,11 @@ namespace TeamAAS_VP.ViewModels.Product
                 //移动机器人至拍照点位,拍照
                 rpoint = new RPoint()
                 {
-                    X = screwCameraPoint[0].X_Position,
-                    Y = screwCameraPoint[0].Y_Position,
-                    Z = screwCameraPoint[0].Z_Position_Start,
-                    U = screwCameraPoint[0].U_Position,
-                    V = screwCameraPoint[0].R_Position,
+                    X = screwCameraPoint[1].X_Position,
+                    Y = screwCameraPoint[1].Y_Position,
+                    Z = screwCameraPoint[1].Z_Position_Start,
+                    U = screwCameraPoint[1].U_Position,
+                    V = screwCameraPoint[1].R_Position,
                 };
                 await Robot.CalibMotionAsync(rpoint, 0);
                 if (_cts.IsCancellationRequested)
@@ -248,13 +249,13 @@ namespace TeamAAS_VP.ViewModels.Product
 
                 for (int i = 0; i < product.ScrewPoints.Count; i++)
                 {
-                    var localPoint = new PointF(product.ScrewCameraPoints[i].X_Position, product.ScrewCameraPoints[i].Y_Position);
+                    var localPoint = new PointF(product.ScrewPoints[i].X_Position, product.ScrewPoints[i].Y_Position);
                     var worldPoint = local.ToOldCoord(localPoint.X, localPoint.Y);
                     var point = product.ScrewCameraPoints[i].Clone();
                     point.X_Position = (float)worldPoint[0];
                     point.Y_Position = (float)worldPoint[1];
                     //计算当前点的高度与screwCameraLocalPoint1的Z轴之间的偏差
-                    var deltaZ = product.ScrewPoints[i].Z_Position_Start - screwCameraPoint[0].Z_Position_Start;
+                    var deltaZ = product.ScrewPoints[i].Z_Position_Start - screwCameraLocalPoint1.Z_Position_Start;
 
                     //计算相机去拍照点位
                     point.X_Position+= cameraOffsetX;
@@ -292,10 +293,10 @@ namespace TeamAAS_VP.ViewModels.Product
                 }
 
             }
-            catch (Exception)
+            catch (Exception ex)
             {
-
-                throw;
+                LogHelper.WriteLogError("通过移动相机自动校准锁付点位是出错!",ex);
+                _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
             }
             finally
             {

+ 1 - 1
TeamAAS-VM/Views/Product/AutoCorrectLockPoint.xaml

@@ -20,7 +20,7 @@
              prism:ViewModelLocator.AutoWireViewModel="True"
              mc:Ignorable="d"
              d:DataContext="{d:DesignInstance Type=vm:AutoCorrectLockPointViewModel}"
-             Height="768"
+             Height="500"
              Width="1024"
              d:Background="White"
              FontFamily="{DynamicResource DefaultFont}">