Răsfoiți Sursa

新增固定下相机免回待机点配置及相关逻辑

在 CalibrationInfo 中新增 FixedDownCameraNoReturnToHome 属性,用于控制固定向下相机是否每次回到待机点。CameraCalibrationService 中相关运动流程增加该属性判断,支持跳过回待机点操作。新增用户交互提示,提升操作安全性和友好性。
孝锋 徐 8 luni în urmă
părinte
comite
d8fc60c19a

+ 10 - 0
TeamAAS-VM/Models/Calibration/CalibrationInfo.cs

@@ -286,6 +286,16 @@ namespace TeamAAS_VP.Models.Calibration
             set { SetProperty(ref _Power, value); }
             set { SetProperty(ref _Power, value); }
         }
         }
 
 
+        private bool _FixedDownCameraNoReturnToHome;
+        /// <summary>
+        /// 固定向下相机时是否不需要每次回到待机点
+        /// </summary>
+        public bool FixedDownCameraNoReturnToHome
+        {
+            get { return _FixedDownCameraNoReturnToHome; }
+            set { SetProperty(ref _FixedDownCameraNoReturnToHome, value); }
+        }
+
         private RPoint _MarkPoint;
         private RPoint _MarkPoint;
         /// <summary>
         /// <summary>
         /// 特征点的坐标
         /// 特征点的坐标

+ 0 - 43
TeamAAS-VM/Services/CalibrationService.cs

@@ -1,46 +1,3 @@
-/* 
-PSEUDOCODE / 设计计划(详尽):
-1. 目标:为 CalibrationService 增加完整中文注释(XML 文档注释 + 行内注释),保持原有逻辑不变。
-2. 对象/职责:
-   - 管理校准项集合(内存):_calibrations(线程安全访问)
-   - 提供读取、保存、添加/更新、删除、批量加载/保存以及像素到位置信息转换的功能
-   - 与文件系统交互:Calibration 列表文件与每个 Calibration 的单独文件、ToolBlock 文件(.vpp)
-3. 方法处理:
-   - GetAllCalibrations: 返回只读集合的快照(加锁,防止并发修改)
-   - GetCalibration: 按 Id 查找校准项(加锁)
-   - AddOrUpdateCalibration:
-       a. 验空
-       b. 在集合中查找是否存在:存在 -> 替换;不存在 -> 追加并设置 Index
-       c. 更新 DateTime
-       d. 确保文件夹存在,写入单个校准 cfg 文件
-       e. 更新并写入 CalibrationList.cfg(Id->Name 映射)
-       f. 保存或加载 ToolBlock(.vpp),如果不存在则尝试使用模板创建
-       g. 返回 calib
-   - RemoveCalibration:
-       a. 在集合中找到并移除(加锁)
-       b. 更新 CalibrationList.cfg
-       c. 重新按 Index 排序并保存每个校准文件
-       d. 返回是否成功移除
-   - LoadAll:
-       a. 确保 CalibrationPath 存在
-       b. 清空集合并创建空索引文件(如果索引文件不存在)
-       c. 读取索引列表,遍历每个条目:加载单个 cfg、尝试加载对应 .vpp、加入集合
-       d. 单个文件异常时忽略,继续加载其他文件
-   - SaveAll:
-       a. 遍历集合,确保对应目录存在,写入每个 cfg,若有 ToolBlock 则保存 .vpp
-       b. 写入索引文件
-   - ConvertPixelToPosition(主转换逻辑):
-       a. 用 calib 的仿射矩阵将像素坐标(X,Y,1)映射到机器人坐标
-       b. 根据 calib.CameraMount 类型选择不同后处理:
-          - MobileJ4 / MobileDown_XYPlatform:将像素->mm 点做基于当前机器人位置与旋转的变换
-          - 其他:若提供 robotCoord,则使用 ToolCoord 计算工具坐标(对 Schneider 角度符号处理)
-       c. 返回 (IsSucceed, X, Y, U)
-4. 注释策略:
-   - 为类与公有方法添加 XML 注释(中文)
-   - 为复杂代码段添加行内注释(中文),解释数学与坐标变换逻辑
-   - 保持所有原始逻辑、签名与行为不变
-*/
-
 using Cognex.VisionPro;
 using Cognex.VisionPro;
 using Cognex.VisionPro.ToolBlock;
 using Cognex.VisionPro.ToolBlock;
 using MathNet.Numerics.LinearAlgebra;
 using MathNet.Numerics.LinearAlgebra;

+ 6 - 6
TeamAAS-VM/Services/CameraCalibrationService.cs

@@ -79,6 +79,7 @@ namespace TeamAAS_VP.Services
                 //夹爪张开为false,夹爪闭合为True
                 //夹爪张开为false,夹爪闭合为True
                 await robot.CalibOutIOAsync(false);
                 await robot.CalibOutIOAsync(false);
             }
             }
+
             var view = new ShowMessage(Lang.提示, Lang.请将校准块放置在吸嘴中心);
             var view = new ShowMessage(Lang.提示, Lang.请将校准块放置在吸嘴中心);
             var result = await DialogHost.Show(view, "CalibToolDialog", null, null, null);
             var result = await DialogHost.Show(view, "CalibToolDialog", null, null, null);
             if (!((bool)result)) return (false, null, 0, 0, 0, 0);
             if (!((bool)result)) return (false, null, 0, 0, 0, 0);
@@ -495,8 +496,7 @@ namespace TeamAAS_VP.Services
 
 
             //-------------------------------------------P0-----------------------------------
             //-------------------------------------------P0-----------------------------------
             //移动机器人至中心点
             //移动机器人至中心点
-
-            if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
+            if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown && !calibrationInfo.FixedDownCameraNoReturnToHome)
             {
             {
                 await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
                 await robot.CalibMotionAsync(calibrationInfo.CenterPoint, 0);
                 //关闭吸气
                 //关闭吸气
@@ -514,7 +514,7 @@ namespace TeamAAS_VP.Services
             RobotP1.X += distance;
             RobotP1.X += distance;
             RobotP2.Y += distance;
             RobotP2.Y += distance;
 
 
-            if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
+            if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown && !calibrationInfo.FixedDownCameraNoReturnToHome)
             {
             {
                 //移动机器人至待机位置
                 //移动机器人至待机位置
                 await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
                 await robot.CalibMotionAsync(calibrationInfo.HomePoint, 0);
@@ -529,7 +529,7 @@ namespace TeamAAS_VP.Services
             PointF P0 = new PointF((float)result.X, (float)result.Y);
             PointF P0 = new PointF((float)result.X, (float)result.Y);
 
 
             //-------------------------------------------P1-----------------------------------
             //-------------------------------------------P1-----------------------------------
-            if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
+            if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown && !calibrationInfo.FixedDownCameraNoReturnToHome)
             {
             {
                 //移动机器人至P0
                 //移动机器人至P0
                 await robot.CalibMotionAsync(RobotP0, 0);
                 await robot.CalibMotionAsync(RobotP0, 0);
@@ -570,7 +570,7 @@ namespace TeamAAS_VP.Services
             PointF P1 = new PointF((float)result.X, (float)result.Y);
             PointF P1 = new PointF((float)result.X, (float)result.Y);
 
 
             //-------------------------------------------P2-----------------------------------
             //-------------------------------------------P2-----------------------------------
-            if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
+            if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown && !calibrationInfo.FixedDownCameraNoReturnToHome)
             {
             {
                 //移动机器人至P1
                 //移动机器人至P1
                 await robot.CalibMotionAsync(RobotP1, 0);
                 await robot.CalibMotionAsync(RobotP1, 0);
@@ -611,7 +611,7 @@ namespace TeamAAS_VP.Services
             PointF P2 = new PointF((float)result.X, (float)result.Y);
             PointF P2 = new PointF((float)result.X, (float)result.Y);
 
 
             //-------------------------------------------P0--------------------------------------
             //-------------------------------------------P0--------------------------------------
-            if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown)
+            if (calibrationInfo.CameraMount == Enums.CameraMount.FixedDown && !calibrationInfo.FixedDownCameraNoReturnToHome)
             {
             {
                 //移动机器人至P2
                 //移动机器人至P2
                 await robot.CalibMotionAsync(RobotP2, 0);
                 await robot.CalibMotionAsync(RobotP2, 0);