| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- using Newtonsoft.Json;
- using System;
- using System.Collections.ObjectModel;
- using System.Linq;
- using TeamAAS.Robot.Models;
- using TeamAAS.Robot.Models.Robot;
- using TeamAAS.Vision.Calibration.Enums;
- namespace TeamAAS.Vision.Calibration.Models
- {
- /// <summary>
- /// 一次标定的完整配置与结果。
- /// 引擎无关:视觉工具以 <see cref="VisionTool"/>(运行时句柄,不序列化)
- /// 与 <see cref="VisionToolRef"/>(持久化引用,如 .vpp 路径)表示,
- /// 具体由当前视觉引擎(VisionPro/VM/Halcon)解释。
- /// </summary>
- [JsonObject(MemberSerialization.OptOut)]
- public class CalibrationInfo : TeamAAS.BindableBase
- {
- private bool _IsCreate;
- /// <summary>正在创建(尚未持久化)。</summary>
- [JsonIgnore]
- public bool IsCreate
- {
- get { return _IsCreate; }
- set { SetProperty(ref _IsCreate, value); }
- }
- private Guid _Id;
- public Guid Id
- {
- get { return _Id; }
- set { SetProperty(ref _Id, value); }
- }
- private int _Index;
- /// <summary>编号。</summary>
- public int Index
- {
- get { return _Index; }
- set { SetProperty(ref _Index, value); }
- }
- private string _Name;
- /// <summary>校准的名称。</summary>
- public string Name
- {
- get { return _Name; }
- set { SetProperty(ref _Name, value); }
- }
- private DateTime _DateTime;
- public DateTime DateTime
- {
- get { return _DateTime; }
- set { SetProperty(ref _DateTime, value); }
- }
- private string _CameraName;
- /// <summary>相机名称。</summary>
- public string CameraName
- {
- get { return _CameraName; }
- set { SetProperty(ref _CameraName, value); }
- }
- private Guid _CameraID;
- /// <summary>相机 ID。</summary>
- public Guid CameraID
- {
- get { return _CameraID; }
- set { SetProperty(ref _CameraID, value); }
- }
- private Guid _RobotId;
- /// <summary>机器人 ID。</summary>
- public Guid RobotId
- {
- get { return _RobotId; }
- set { SetProperty(ref _RobotId, value); }
- }
- private Guid _FeederId;
- /// <summary>Feeder(喂料器/光源)ID。</summary>
- public Guid FeederId
- {
- get { return _FeederId; }
- set { SetProperty(ref _FeederId, value); }
- }
- private CameraMount _CameraMount;
- /// <summary>相机安装方式。</summary>
- public CameraMount CameraMount
- {
- get { return _CameraMount; }
- set { SetProperty(ref _CameraMount, value); }
- }
- private PickInfo _Pick;
- /// <summary>取料方式(吸取/夹取 + IO 点位)。</summary>
- public PickInfo Pick
- {
- get { return _Pick; }
- set { SetProperty(ref _Pick, value); }
- }
- private int _Brightness;
- /// <summary>光源亮度。</summary>
- public int Brightness
- {
- get { return _Brightness; }
- set { SetProperty(ref _Brightness, value); }
- }
- private float _ExposureTime;
- /// <summary>相机曝光时间。</summary>
- public float ExposureTime
- {
- get { return _ExposureTime; }
- set { SetProperty(ref _ExposureTime, value); }
- }
- private float _Gain;
- /// <summary>相机增益。</summary>
- public float Gain
- {
- get { return _Gain; }
- set { SetProperty(ref _Gain, value); }
- }
- private CalibTechP0Mode _CalibTechP0Mode;
- /// <summary>移动相机中心作为 P0 还是手动示教 P0。</summary>
- public CalibTechP0Mode CalibTechP0Mode
- {
- get { return _CalibTechP0Mode; }
- set { SetProperty(ref _CalibTechP0Mode, value); }
- }
- private RPoint _CenterPoint;
- /// <summary>中心点。</summary>
- public RPoint CenterPoint
- {
- get { return _CenterPoint; }
- set { SetProperty(ref _CenterPoint, value); }
- }
- private RPoint _HomePoint;
- /// <summary>待机点。</summary>
- public RPoint HomePoint
- {
- get { return _HomePoint; }
- set { SetProperty(ref _HomePoint, value); }
- }
- private double _Width;
- /// <summary>机器人移动的范围 X。</summary>
- public double Width
- {
- get { return _Width; }
- set { SetProperty(ref _Width, value); }
- }
- private double _Height;
- /// <summary>机器人移动的范围 Y。</summary>
- public double Height
- {
- get { return _Height; }
- set { SetProperty(ref _Height, value); }
- }
- private double _Angle = 180;
- /// <summary>机器人移动的范围 U(旋转标定用角度)。</summary>
- public double Angle
- {
- get { return _Angle; }
- set { SetProperty(ref _Angle, value); }
- }
- private RobotTool _Tool;
- /// <summary>工具坐标(TCP)。</summary>
- public RobotTool Tool
- {
- get { return _Tool; }
- set { SetProperty(ref _Tool, value); }
- }
- private RobotArm _Arm;
- /// <summary>Arm。</summary>
- public RobotArm Arm
- {
- get { return _Arm; }
- set { SetProperty(ref _Arm, value); }
- }
- private int _Speed;
- public int Speed
- {
- get { return _Speed; }
- set { SetProperty(ref _Speed, value); }
- }
- private int _Accel;
- public int Accel
- {
- get { return _Accel; }
- set { SetProperty(ref _Accel, value); }
- }
- private int _WaitPhoto;
- public int WaitPhoto
- {
- get { return _WaitPhoto; }
- set { SetProperty(ref _WaitPhoto, value); }
- }
- private int _WaitSuction;
- /// <summary>吸真空延时。</summary>
- public int WaitSuction
- {
- get { return _WaitSuction; }
- set { SetProperty(ref _WaitSuction, value); }
- }
- private int _WaitBlow;
- /// <summary>破真空延时。</summary>
- public int WaitBlow
- {
- get { return _WaitBlow; }
- set { SetProperty(ref _WaitBlow, value); }
- }
- private bool _Power;
- public bool Power
- {
- get { return _Power; }
- set { SetProperty(ref _Power, value); }
- }
- private bool _IsDistortionCorrection;
- /// <summary>是否进行畸变校正。</summary>
- public bool IsDistortionCorrection
- {
- get { return _IsDistortionCorrection; }
- set { SetProperty(ref _IsDistortionCorrection, value); }
- }
- private RPoint _MarkPoint;
- /// <summary>特征点的坐标(移动相机模式下记录标定块绝对坐标)。</summary>
- public RPoint MarkPoint
- {
- get { return _MarkPoint; }
- set { SetProperty(ref _MarkPoint, value); }
- }
- private ObservableCollection<RobotPixelPoint> _CalibPoints;
- /// <summary>9 点校准点(机器人坐标与像素坐标对应)。</summary>
- public ObservableCollection<RobotPixelPoint> CalibPoints
- {
- get { return _CalibPoints; }
- set { SetProperty(ref _CalibPoints, value); }
- }
- private double[,] _RobotCameraRotationMatrix;
- /// <summary>机器人与相机之间的旋转矩阵。</summary>
- public double[,] RobotCameraRotationMatrix
- {
- get { return _RobotCameraRotationMatrix; }
- set { SetProperty(ref _RobotCameraRotationMatrix, value); }
- }
- private double _PixelScaleX;
- /// <summary>图像 X 方向像素与毫米缩放系数,mm/pixel。</summary>
- public double PixelScaleX
- {
- get { return _PixelScaleX; }
- set { SetProperty(ref _PixelScaleX, value); }
- }
- private double _PixelScaleY;
- /// <summary>图像 Y 方向像素与毫米缩放系数,mm/pixel。</summary>
- public double PixelScaleY
- {
- get { return _PixelScaleY; }
- set { SetProperty(ref _PixelScaleY, value); }
- }
- private double[,] _AffineTransformationMaterial;
- /// <summary>仿射变换 2*3 矩阵(像素 → 机器人)。</summary>
- public double[,] AffineTransformationMaterial
- {
- get { return _AffineTransformationMaterial; }
- set { SetProperty(ref _AffineTransformationMaterial, value); }
- }
- private CalibrationResult _CalibrationResult;
- /// <summary>校准结果。</summary>
- public CalibrationResult CalibrationResult
- {
- get { return _CalibrationResult; }
- set { SetProperty(ref _CalibrationResult, value); }
- }
- private CalibrationTestResult _CalibrationTestResult;
- /// <summary>校准验证结果。</summary>
- public CalibrationTestResult CalibrationTestResult
- {
- get { return _CalibrationTestResult; }
- set { SetProperty(ref _CalibrationTestResult, value); }
- }
- private string _VisionToolRef;
- /// <summary>视觉标定工具的持久化引用(如 .vpp 路径),随引擎解释。</summary>
- public string VisionToolRef
- {
- get { return _VisionToolRef; }
- set { SetProperty(ref _VisionToolRef, value); }
- }
- /// <summary>视觉标定工具的运行时句柄(引擎私有对象,不序列化)。</summary>
- [JsonIgnore]
- public object VisionTool { get; set; }
- /// <summary>畸变校正工具的运行时句柄(引擎私有对象,不序列化)。</summary>
- [JsonIgnore]
- public object DistortionTool { get; set; }
- public CalibrationInfo Clone()
- {
- return new CalibrationInfo
- {
- Id = this.Id,
- Index = this.Index,
- Name = this.Name,
- DateTime = this.DateTime,
- CameraName = this.CameraName,
- CameraID = this.CameraID,
- RobotId = this.RobotId,
- FeederId = this.FeederId,
- CameraMount = this.CameraMount,
- Pick = this.Pick?.Clone(),
- Brightness = this.Brightness,
- ExposureTime = this.ExposureTime,
- Gain = this.Gain,
- CalibTechP0Mode = this.CalibTechP0Mode,
- CenterPoint = this.CenterPoint?.Clone(),
- HomePoint = this.HomePoint?.Clone(),
- Width = this.Width,
- Height = this.Height,
- Angle = this.Angle,
- Tool = this.Tool?.Copy(),
- Arm = this.Arm,
- Speed = this.Speed,
- Accel = this.Accel,
- WaitPhoto = this.WaitPhoto,
- WaitSuction = this.WaitSuction,
- WaitBlow = this.WaitBlow,
- Power = this.Power,
- IsDistortionCorrection = this.IsDistortionCorrection,
- MarkPoint = this.MarkPoint?.Clone(),
- CalibPoints = new ObservableCollection<RobotPixelPoint>((this.CalibPoints ?? new ObservableCollection<RobotPixelPoint>()).Select(p => p.Clone())),
- RobotCameraRotationMatrix = (double[,])this.RobotCameraRotationMatrix?.Clone(),
- PixelScaleX = this.PixelScaleX,
- PixelScaleY = this.PixelScaleY,
- AffineTransformationMaterial = (double[,])this.AffineTransformationMaterial?.Clone(),
- VisionToolRef = this.VisionToolRef,
- };
- }
- }
- }
|