



*像素坐标Row1:=[1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6]Column1:=[1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3]*机械坐标Row2:=[50,51.999,54.999,56.999,59.999,62.996,-4.999,-3,0,1.999,4.999,7.995,-59.998,-57.001,-55.001,-52.001,-49.003,-45.005]Column2:=[-93.3,-47.299,0.002,45.499,91.498,135.493,-92.301,-44.3,0,46.999,91.497,135.494,-90.297,-44.297,1.003,46.999,91.497,134.494]*求解放射变换矩阵vector_to_hom_mat2d (Row1, Column1, Row2, Column2, HomMat2D)*保存变换矩阵到HomMat2D.mat中serialize_hom_mat2d (HomMat2D, SerializedItemHandle)open_file ('HomMat2D.mat', 'output_binary', FileHandle) fwrite_serialized_item (FileHandle, SerializedItemHandle) close_file (FileHandle)
private Position updatePoiMatrix(Position pcbPoi, Position dstPoi) { //到上一个放pcb的点位 this.currentRobot.GoToPosition(pcbPoi); this.currentCylinder.Open(); //到达待测量的点位 this.currentRobot.GoToPosition(dstPoi); this.currentRobot.GoToPosition(dstPoi); //放板 this.currentCylinder.Close(); Thread.Sleep(600); Position pUp = dstPoi.Copy(); pUp.Z = this.currentRobot.GetSafeZ(); this.currentRobot.GoToPosition(pUp); //到达安全点位 this.currentRobot.GoToPosition(safePoi); //拍照获取mark点 Position poi1 = this.getMarkPoi(); this.currentRobot.GoToPosition(dstPoi); //打开 this.currentCylinder.Open(); //先上升一定的高度再旋转 Position dstPoi2 = dstPoi.Copy(); dstPoi2.Z = this.currentRobot.GetSafeZ(); this.currentRobot.GoToPosition(dstPoi2); //旋转180度 if (dstPoi2.U > 90) { dstPoi2.U -= 180; } else if (dstPoi2.U < -90) { dstPoi2.U += 180; } else { dstPoi2.U += 180; } this.currentRobot.GoToPosition(dstPoi2); dstPoi2.Z = dstPoi.Z; this.currentRobot.GoToPosition(dstPoi2); //放板 this.currentCylinder.Close(); Thread.Sleep(600); //到达安全点位 this.currentRobot.GoToPosition(safePoi); //拍照获取mark2点 Position poi2 = this.getMarkPoi(); //更新对应的数组 imagePoiList.Add(new Position() { X = (poi1.X + poi2.X) / 2, Y = (poi1.Y + poi2.Y) / 2 }); robotPoiList.Add(dstPoi2.Copy()); //返回取PCB的最新位置 return dstPoi2; } public void SaveMat(List<Position> imageList, List<Position> robotPoiList, string path) { HTuple imageXList = new HTuple(), imageYList = new HTuple(); HTuple robotXList = new HTuple(), robotYList = new HTuple(); for (int i = 0; i < imageList.Count; i++) { imageXList[i] = imageList[i].X; imageYList[i] = imageList[i].Y; robotXList[i] = robotPoiList[i].X; robotYList[i] = robotPoiList[i].Y; } HTuple hv_HomMat2D = new HTuple(), hv_SerializedItemHandle = new HTuple(); HTuple hv_FileHandle = new HTuple(); ////标定 hv_HomMat2D.Dispose(); HOperatorSet.VectorToHomMat2d(imageXList, imageYList, robotXList, robotYList, out hv_HomMat2D); //保存变换矩阵 hv_SerializedItemHandle.Dispose(); HOperatorSet.SerializeHomMat2d(hv_HomMat2D, out hv_SerializedItemHandle); hv_FileHandle.Dispose(); HOperatorSet.OpenFile(path, "output_binary", out hv_FileHandle); HOperatorSet.FwriteSerializedItem(hv_FileHandle, hv_SerializedItemHandle); HOperatorSet.CloseFile(hv_FileHandle); imageXList.Dispose(); imageYList.Dispose(); robotXList.Dispose(); robotYList.Dispose(); hv_HomMat2D.Dispose(); hv_SerializedItemHandle.Dispose(); hv_FileHandle.Dispose(); }|
作者:Bonker 出处:http://www.cnblogs.com/Bonker QQ:519841366 |