徐孝锋 8 ماه پیش
والد
کامیت
ae2d00bbda

+ 1 - 0
TeamAAS-VM/Services/CameraCalibrationService.cs

@@ -805,6 +805,7 @@ namespace TeamAAS_VP.Services
                 calibrationInfo.CenterPoint.X = (float)autoMoveResult.X;
                 calibrationInfo.CenterPoint.Y = (float)autoMoveResult.Y;
                 calibrationInfo.MarkPoint = calibrationInfo.CenterPoint.Clone();
+                calibrationInfo.RobotCameraRotationMatrix = robotCameraRotationMatrix.RotationMatrix.ToArray();
             }
 
             /// <summary>

+ 1 - 1
TeamAAS-VM/ViewModels/Calibration/CalibrationAutoViewModel.cs

@@ -192,7 +192,7 @@ namespace TeamAAS_VP.ViewModels.Calibration
                 {
                     if (_cts != null && !_cts.IsCancellationRequested)
                         _cts.Cancel();
-                    _cts.Dispose();
+                    _cts?.Dispose();
                     _cts = null;
                 }
                 catch (Exception)

+ 37 - 0
TeamAAS-VM/ViewModels/Calibration/CalibrationTeachCenterPointViewModel.cs

@@ -9,6 +9,7 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Security.Cryptography;
+using System.Threading.Tasks;
 using System.Windows;
 using Team.FFFeederService.Interfaces;
 using TeamAAS_VP;
@@ -100,7 +101,11 @@ namespace TeamAAS_VP.ViewModels.Calibration
         public DelegateCommand TechMarkPointCommand =>
             _TechMarkPointCommand ?? (_TechMarkPointCommand = new DelegateCommand(ExecuteTechMarkPointCommand));
 
+        private DelegateCommand _MoveCenterCommand;
+        public DelegateCommand MoveCenterCommand =>
+            _MoveCenterCommand ?? (_MoveCenterCommand = new DelegateCommand(ExecuteMoveCenterCommand));
 
+        
         #endregion
 
         #region 事件
@@ -285,6 +290,38 @@ namespace TeamAAS_VP.ViewModels.Calibration
                 _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
             }
         }
+
+        /// <summary>
+        /// 移动至中心点
+        /// </summary>
+        async void ExecuteMoveCenterCommand()
+        {
+            if (Robot == null || !Robot.IsConnected) return;
+            try
+            {
+                if (SelectCalibration.CenterPoint.X==0 && SelectCalibration.CenterPoint.Y==0)
+                {
+                    MessageBox.Show("检测到机器人的XY为0,可能点位未示教!将不允许移动机器人");
+                    return;
+                }
+
+                if (MessageBox.Show("是否移动机器人至中心点?请确认安全?","移动机器人",MessageBoxButton.YesNo,MessageBoxImage.Asterisk)!= MessageBoxResult.Yes)
+                {
+                    return;
+                }
+
+
+                await Robot.CalibMotionAsync(SelectCalibration.CenterPoint,0);
+                
+                LogHelper.WriteLogInfo($"相机校准-移动机器人至中心点界面示教待机点");
+                _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"成功! X:{SelectCalibration.CenterPoint.X} Y:{SelectCalibration.CenterPoint.Y}  Z:{SelectCalibration.CenterPoint.Z}", Duration = 1 });
+            }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLogError("相机校准-示教中心点界面示教中心点时出错!", ex);
+                _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = ex.Message, Duration = 1 });
+            }
+        }
         #endregion
 
         #region 继承

+ 17 - 2
TeamAAS-VM/ViewModels/Calibration/FixedUpCameraFindP0ViewModel.cs

@@ -14,6 +14,7 @@ using System.IO;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Windows;
+using System.Windows.Shapes;
 using Team.FFFeederService.Interfaces;
 using TeamAAS_VP.Core;
 using TeamAAS_VP.Enums;
@@ -144,7 +145,7 @@ namespace TeamAAS_VP.ViewModels.Calibration
                 {
                     Camera = _cameraService.GetCamera(value.Id);
                     SelectCalibration.FixedUpCameraFindP0Info.CameraId = value.Id;
-                    SelectCalibration.FixedUpCameraFindP0Info.CameraId = value.Id;
+                    SelectCalibration.FixedUpCameraFindP0Info.CameraName = value.CameraName;
                 }
             }
         }
@@ -163,6 +164,11 @@ namespace TeamAAS_VP.ViewModels.Calibration
             set
             {
                 SetProperty(ref _SelectedCalibration, value);
+                if (value!=null)
+                {
+                    SelectCalibration.FixedUpCameraFindP0Info.CalibrationId = value.Id;
+                    SelectCalibration.FixedUpCameraFindP0Info.CalibrationName = value.Name;
+                }
             }
         }
 
@@ -240,6 +246,10 @@ namespace TeamAAS_VP.ViewModels.Calibration
             try
             {
                 string prcPath = FilePath.CalibrationPath + "//" + SelectCalibration.Name + "//" + "FixedUpCameraTool.vpp";
+                if (!Directory.Exists(System.IO.Path.GetDirectoryName(prcPath)))
+                {
+                    Directory.CreateDirectory(System.IO.Path.GetDirectoryName(prcPath));
+                }
                 CogSerializer.SaveObjectToFile(ToolBlockEdit.Subject, prcPath);
                 NavigationParameters param = new NavigationParameters();
                 param.Add("SelectCalibration", SelectCalibration);
@@ -277,6 +287,11 @@ namespace TeamAAS_VP.ViewModels.Calibration
         {
             try
             {
+                if (Camera == null)
+                {
+                    MessageBox.Show("请先选择相机!");
+                    return;
+                }
                 ToolBlockEdit.Subject.Inputs["InputImage"].Value = Camera.Grab();
                 ToolBlockEdit.Subject.Run();
             }
@@ -411,7 +426,7 @@ namespace TeamAAS_VP.ViewModels.Calibration
             CalibrationList = new ObservableCollection<CalibrationInfo>(_calibrationServvice.GetAllCalibrations());
             if (SelectCalibration.FixedUpCameraFindP0Info.CalibrationId != Guid.Empty)
             {
-                SelectCalibration = CalibrationList.FirstOrDefault(c => c.Id == SelectCalibration.FixedUpCameraFindP0Info.CalibrationId);
+                SelectedCalibration = CalibrationList.FirstOrDefault(c => c.Id == SelectCalibration.FixedUpCameraFindP0Info.CalibrationId);
             }
 
             ExposureTime = SelectCalibration.ExposureTime;

+ 15 - 0
TeamAAS-VM/Views/Calibration/CalibrationTeachCenterPoint.xaml

@@ -86,6 +86,8 @@
                     <ColumnDefinition Width="auto"
                                       MinWidth="100" />
                     <ColumnDefinition Width="*" />
+                    <ColumnDefinition Width="auto"
+                                      />
                 </Grid.ColumnDefinitions>
                 <Grid.Resources>
                     <Style TargetType="TextBlock">
@@ -113,6 +115,19 @@
                         <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/FeederCenterPoint.png" />
                     </Button.ToolTip>
                 </Button>
+                <Button Content="移动至"
+                        Grid.Row="0"
+                        Grid.Column="2"
+                        Margin="5,0"
+                        HorizontalAlignment="Center"
+                        VerticalAlignment="Center"
+                        materialDesign:ButtonAssist.CornerRadius="10"
+                        Style="{StaticResource MaterialDesignRaisedButton}"
+                        Command="{Binding MoveCenterCommand}">
+                    <Button.ToolTip>
+                        <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/FeederCenterPoint.png" />
+                    </Button.ToolTip>
+                </Button>
                 <TextBlock Grid.Row="1"
                            Grid.ColumnSpan="2">
                     <TextBlock.Text>