CalibrationInfo.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. using MathNet.Numerics.LinearAlgebra;
  2. using Newtonsoft.Json;
  3. using Prism.Mvvm;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Media.Media3D;
  11. using TeamAAS_VP.Enums;
  12. namespace TeamAAS_VP.Models
  13. {
  14. [JsonObject(MemberSerialization.OptOut)]
  15. public class CalibrationInfo : BindableBase
  16. {
  17. private bool _IsCreate;
  18. /// <summary>
  19. /// 正在创建
  20. /// </summary>
  21. [JsonIgnore]
  22. public bool IsCreate
  23. {
  24. get { return _IsCreate; }
  25. set { SetProperty(ref _IsCreate, value); }
  26. }
  27. private Guid _Id;
  28. public Guid Id
  29. {
  30. get { return _Id; }
  31. set { SetProperty(ref _Id, value); }
  32. }
  33. private string _Name;
  34. /// <summary>
  35. /// 校准的名称
  36. /// </summary>
  37. public string Name
  38. {
  39. get { return _Name; }
  40. set { SetProperty(ref _Name, value); }
  41. }
  42. private DateTime _DateTime;
  43. public DateTime DateTime
  44. {
  45. get { return _DateTime; }
  46. set { SetProperty(ref _DateTime,value); }
  47. }
  48. private string _CameraName;
  49. /// <summary>
  50. /// 相机名称
  51. /// </summary>
  52. public string CameraName
  53. {
  54. get { return _CameraName; }
  55. set { SetProperty(ref _CameraName,value); }
  56. }
  57. private Guid _CameraID;
  58. /// <summary>
  59. /// 相机ID
  60. /// </summary>
  61. public Guid CameraID
  62. {
  63. get { return _CameraID; }
  64. set { SetProperty(ref _CameraID, value); }
  65. }
  66. private Guid _RobotId;
  67. /// <summary>
  68. /// 机器人
  69. /// </summary>
  70. public Guid RobotId
  71. {
  72. get { return _RobotId; }
  73. set { SetProperty(ref _RobotId,value); }
  74. }
  75. private Guid _FeederId;
  76. /// <summary>
  77. /// Feeder
  78. /// </summary>
  79. public Guid FeederId
  80. {
  81. get { return _FeederId; }
  82. set { SetProperty(ref _FeederId, value); }
  83. }
  84. private CameraMount _CameraMount;
  85. /// <summary>
  86. /// 相机安装方式
  87. /// </summary>
  88. public CameraMount CameraMount
  89. {
  90. get { return _CameraMount; }
  91. set { SetProperty(ref _CameraMount, value); }
  92. }
  93. private PickInfo _Pick;
  94. /// <summary>
  95. /// 取料方式
  96. /// </summary>
  97. public PickInfo Pick
  98. {
  99. get { return _Pick; }
  100. set { SetProperty(ref _Pick, value); }
  101. }
  102. private int _Brightness;
  103. /// <summary>
  104. /// 光源亮度
  105. /// </summary>
  106. public int Brightness
  107. {
  108. get { return _Brightness; }
  109. set { SetProperty(ref _Brightness, value); }
  110. }
  111. private float _ExposureTime;
  112. /// <summary>
  113. /// 相机曝光时间
  114. /// </summary>
  115. public float ExposureTime
  116. {
  117. get { return _ExposureTime; }
  118. set { SetProperty(ref _ExposureTime, value); }
  119. }
  120. private float _Gain;
  121. /// <summary>
  122. /// 相机增益
  123. /// </summary>
  124. public float Gain
  125. {
  126. get { return _Gain; }
  127. set { SetProperty(ref _Gain, value); }
  128. }
  129. private CalibTechP0Mode _CalibTechP0Mode;
  130. /// <summary>
  131. /// 移动相机中心作为P0还是手动示教P0
  132. /// </summary>
  133. public CalibTechP0Mode CalibTechP0Mode
  134. {
  135. get { return _CalibTechP0Mode; }
  136. set { SetProperty(ref _CalibTechP0Mode, value); }
  137. }
  138. private RPoint _CenterPoint;
  139. /// <summary>
  140. /// 中心点
  141. /// </summary>
  142. public RPoint CenterPoint
  143. {
  144. get { return _CenterPoint; }
  145. set { SetProperty(ref _CenterPoint,value); }
  146. }
  147. private RPoint _HomePoint;
  148. /// <summary>
  149. /// 待机点
  150. /// </summary>
  151. public RPoint HomePoint
  152. {
  153. get { return _HomePoint; }
  154. set { SetProperty(ref _HomePoint, value); }
  155. }
  156. private double _Width;
  157. /// <summary>
  158. /// 机器人移动的范围X
  159. /// </summary>
  160. public double Width
  161. {
  162. get { return _Width; }
  163. set { SetProperty(ref _Width,value); }
  164. }
  165. private double _Height;
  166. /// <summary>
  167. /// 机器人移动的范围Y
  168. /// </summary>
  169. public double Height
  170. {
  171. get { return _Height; }
  172. set { SetProperty(ref _Height, value); }
  173. }
  174. private double _Angle=180;
  175. /// <summary>
  176. /// 机器人移动的范围U
  177. /// </summary>
  178. public double Angle
  179. {
  180. get { return _Angle; }
  181. set { SetProperty(ref _Angle, value); }
  182. }
  183. private RobotTool _Tool;
  184. /// <summary>
  185. /// 工具坐标
  186. /// </summary>
  187. public RobotTool Tool
  188. {
  189. get { return _Tool; }
  190. set { SetProperty(ref _Tool,value); }
  191. }
  192. private RobotArm _Arm;
  193. /// <summary>
  194. /// Arm
  195. /// </summary>
  196. public RobotArm Arm
  197. {
  198. get { return _Arm; }
  199. set { SetProperty(ref _Arm, value); }
  200. }
  201. private int _Speed;
  202. public int Speed
  203. {
  204. get { return _Speed; }
  205. set { SetProperty(ref _Speed,value); }
  206. }
  207. private int _Accel;
  208. public int Accel
  209. {
  210. get { return _Accel; }
  211. set { SetProperty(ref _Accel, value); }
  212. }
  213. private int _WaitPhoto;
  214. public int WaitPhoto
  215. {
  216. get { return _WaitPhoto; }
  217. set { SetProperty(ref _WaitPhoto, value); }
  218. }
  219. private int _WaitSuction;
  220. /// <summary>
  221. /// 吸真空延时
  222. /// </summary>
  223. public int WaitSuction
  224. {
  225. get { return _WaitSuction; }
  226. set { SetProperty(ref _WaitSuction, value); }
  227. }
  228. private int _WaitBlow;
  229. /// <summary>
  230. /// 破真空延时
  231. /// </summary>
  232. public int WaitBlow
  233. {
  234. get { return _WaitBlow; }
  235. set { SetProperty(ref _WaitBlow, value); }
  236. }
  237. private bool _Power;
  238. public bool Power
  239. {
  240. get { return _Power; }
  241. set { SetProperty(ref _Power, value); }
  242. }
  243. private RPoint _MarkPoint;
  244. /// <summary>
  245. /// 特征点的坐标
  246. /// </summary>
  247. public RPoint MarkPoint
  248. {
  249. get { return _MarkPoint; }
  250. set { SetProperty(ref _MarkPoint, value); }
  251. }
  252. private ObservableCollection<RobotPixelPoint> _CalibPoints;
  253. /// <summary>
  254. /// 9点校准点
  255. /// </summary>
  256. public ObservableCollection<RobotPixelPoint> CalibPoints
  257. {
  258. get { return _CalibPoints; }
  259. set { SetProperty(ref _CalibPoints,value); }
  260. }
  261. private double[,] _RobotCameraRotationMatrix;
  262. /// <summary>
  263. /// 机器人与相机之间的旋转矩阵
  264. /// </summary>
  265. public double[,] RobotCameraRotationMatrix
  266. {
  267. get { return _RobotCameraRotationMatrix; }
  268. set { SetProperty(ref _RobotCameraRotationMatrix,value); }
  269. }
  270. private double _PixelScaleX;
  271. /// <summary>
  272. /// 图像X方向像素与毫米缩放系数,mm/pixel
  273. /// </summary>
  274. public double PixelScaleX
  275. {
  276. get { return _PixelScaleX; }
  277. set { SetProperty(ref _PixelScaleX, value); }
  278. }
  279. private double _PixelScaleY;
  280. /// <summary>
  281. /// 图像Y方向像素与毫米缩放系数,mm/pixel
  282. /// </summary>
  283. public double PixelScaleY
  284. {
  285. get { return _PixelScaleX; }
  286. set { SetProperty(ref _PixelScaleX, value); }
  287. }
  288. private double[,] _AffineTransformationMaterial;
  289. /// <summary>
  290. /// 仿射变换2*3矩阵
  291. /// </summary>
  292. public double[,] AffineTransformationMaterial
  293. {
  294. get { return _AffineTransformationMaterial; }
  295. set { SetProperty(ref _AffineTransformationMaterial, value); }
  296. }
  297. private CalibrationResult _CalibrationResult;
  298. /// <summary>
  299. /// 校准结果
  300. /// </summary>
  301. public CalibrationResult CalibrationResult
  302. {
  303. get { return _CalibrationResult; }
  304. set { SetProperty(ref _CalibrationResult,value); }
  305. }
  306. private CalibrationTestResult _CalibrationTestResult;
  307. public CalibrationTestResult CalibrationTestResult
  308. {
  309. get { return _CalibrationTestResult; }
  310. set { SetProperty(ref _CalibrationTestResult,value); }
  311. }
  312. /// <summary>
  313. /// 流程
  314. /// </summary>
  315. [JsonIgnore]
  316. public Cognex.VisionPro.ToolBlock.CogToolBlock ToolBlock { get; set; }
  317. public CalibrationInfo Clone()
  318. {
  319. try
  320. {
  321. return JsonConvert.DeserializeObject<CalibrationInfo>(JsonConvert.SerializeObject(this));
  322. }
  323. catch (Exception)
  324. {
  325. return this;
  326. }
  327. }
  328. }
  329. }