CalibrationInfo.cs 10 KB

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