*畫素座標
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 |