|
|
@ -15,6 +15,7 @@ import a8k.type.*; |
|
|
|
import a8k.type.cfg.Pos2d; |
|
|
|
import a8k.type.cfg.Pos3d; |
|
|
|
import a8k.type.exception.AppException; |
|
|
|
import a8k.type.pos.TipPos; |
|
|
|
import a8k.type.type.TipGroup; |
|
|
|
import a8k.utils.ZJsonHelper; |
|
|
|
import a8k.utils.ZSimplAlgo; |
|
|
@ -66,12 +67,6 @@ public class HbotTipPosCalibration { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ExtApiFn(name = "获取所有坐标", group = "基础", order = 1) |
|
|
|
public Object getPoss() throws AppException { |
|
|
|
return hbotTipPosMgr.getParams(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 测试工具 |
|
|
|
@ExtApiFn(name = "归零", group = "测试工具", order = 11) |
|
|
|
public void moveToZero() throws AppException { |
|
|
@ -92,139 +87,65 @@ public class HbotTipPosCalibration { |
|
|
|
hbotDriver.enable(0); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ExtApiFn(name = "设置上下文", group = "设置上下文", order = 20) |
|
|
|
public void setContext(TipGroup tipGroup) throws AppException { |
|
|
|
this.tipGroup = tipGroup; |
|
|
|
@ExtApiFn(name = "获取所有坐标", group = "测试工具", order = 14) |
|
|
|
public Object getPoss() throws AppException { |
|
|
|
return hbotTipPosMgr.getParams(); |
|
|
|
} |
|
|
|
|
|
|
|
// |
|
|
|
// 标定 |
|
|
|
// |
|
|
|
|
|
|
|
List<TipRefPoint> tipRefPosList; |
|
|
|
Pos3d tip000; |
|
|
|
Double tipdx; |
|
|
|
Double tipdy; |
|
|
|
|
|
|
|
@ExtApiFn(name = "清空参考点", group = "辅助标定", order = 20) |
|
|
|
public void startCalibrateTipPos() throws AppException { |
|
|
|
Assert.isTrue(tipGroup != null, "请先设置上下文"); |
|
|
|
tipRefPosList = new java.util.ArrayList<>(); |
|
|
|
tipdx = 0.0; |
|
|
|
tipdy = 0.0; |
|
|
|
tip000 = new Pos3d(0, 0, 0); |
|
|
|
} |
|
|
|
|
|
|
|
@ExtApiFn(name = "添加Tip参考点", group = "辅助标定", order = 21) |
|
|
|
public Object addTipPosRefPoint(TipRowNum row, TipColumnNum columnNum) throws AppException { |
|
|
|
@ExtApiFn(name = "测试Tip坐标", group = "测量Tip000坐标", order = 31) |
|
|
|
public Pos3d measuringTipPos() throws AppException { |
|
|
|
enableModule(); |
|
|
|
Pos2d xypos = hbotDriver.readPos(); |
|
|
|
pipetteCtrlDriver.zMotorMeasureDistance(); |
|
|
|
Integer z = pipetteCtrlDriver.zMotorReadMeasureDistanceResult(); |
|
|
|
pipetteCtrlDriver.putTipBlock(); |
|
|
|
TipRefPoint tipRefPoint = new TipRefPoint(row, columnNum, new Pos3d(xypos.x, xypos.y, z)); |
|
|
|
tipRefPosList.add(tipRefPoint); |
|
|
|
var pos = new Pos3d(xypos.x, xypos.y, z); |
|
|
|
disableModule(); |
|
|
|
|
|
|
|
Map<String, Object> ret = new java.util.HashMap<>(); |
|
|
|
ret.put("newPoint", tipRefPoint); |
|
|
|
ret.put("computeResult", computeTipGroupPos()); |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
@ExtApiFn(name = "删除上一个Tip参考点", group = "辅助标定", order = 22) |
|
|
|
public Object removeTipPosRefPoint() throws AppException { |
|
|
|
if (!tipRefPosList.isEmpty()) { |
|
|
|
tipRefPosList.remove(tipRefPosList.size() - 1); |
|
|
|
} |
|
|
|
Map<String, Object> ret = new java.util.HashMap<>(); |
|
|
|
ret.put("computeResult", computeTipGroupPos()); |
|
|
|
return ret; |
|
|
|
return pos; |
|
|
|
} |
|
|
|
|
|
|
|
Pos3d tip000Pos; |
|
|
|
Pos3d tip119Pos; |
|
|
|
|
|
|
|
@ExtApiFn(name = "计算Tip坐标", group = "辅助标定", order = 23) |
|
|
|
public ObjectNode computeTipGroupPos() throws AppException { |
|
|
|
TipRefPoint tip_ref_01_01 = tipRefPosList.stream().filter(tipRefPoint -> tipRefPoint.eq(TipRowNum.ROW00, TipColumnNum.Colu00)).findFirst().orElse(null); |
|
|
|
|
|
|
|
if (tip_ref_01_01 == null) { |
|
|
|
throw new AppException(A8kEcode.CALIBRATION_TIP_REF_POINT_NOT_ENOUGH); |
|
|
|
@ExtApiFn(name = "步骤1.测量Tip000坐标", group = "测量Tip间距", order = 40) |
|
|
|
public void measuringTip000Pos() throws AppException { |
|
|
|
tip000Pos = measuringTipPos(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//计算tip01_01_x,取所有第一列tip坐标x的平局值 |
|
|
|
Double tip01_01_x = ZSimplAlgo.computeAverage( |
|
|
|
tipRefPosList.stream().filter(tipRefPoint -> tipRefPoint.col == TipColumnNum.Colu00). |
|
|
|
map(tipRefPoint -> Double.valueOf(tipRefPoint.pos.x)).toList() |
|
|
|
); |
|
|
|
|
|
|
|
//计算tip01_01_y,取所有第1行tip坐标y的平局值 |
|
|
|
Double tip01_01_y = ZSimplAlgo.computeAverage( |
|
|
|
tipRefPosList.stream().filter(tipRefPoint -> tipRefPoint.row == TipRowNum.ROW00). |
|
|
|
map(tipRefPoint -> Double.valueOf(tipRefPoint.pos.y)).toList() |
|
|
|
); |
|
|
|
|
|
|
|
//计算z,取所有tip坐标z的平局值 |
|
|
|
Double tip01_01_z = ZSimplAlgo.computeAverage( |
|
|
|
tipRefPosList.stream().map(tipRefPoint -> Double.valueOf(tipRefPoint.pos.z)).toList() |
|
|
|
); |
|
|
|
//计算dx,所有点到tip01_01的距离除以行数 之后的平均值 |
|
|
|
Double dx = ZSimplAlgo.computeAverage( |
|
|
|
tipRefPosList.stream().filter(point -> !point.col.equals(TipColumnNum.Colu00)). |
|
|
|
map(point -> Math.abs(point.pos.x - Double.valueOf(tip_ref_01_01.pos.x)) / point.col.ordinal()).toList() |
|
|
|
); |
|
|
|
//计算dy,所有点到tip01_01的距离除以列数 之后的平均值 |
|
|
|
Double dy = ZSimplAlgo.computeAverage( |
|
|
|
tipRefPosList.stream().filter(point -> !point.row.equals(TipRowNum.ROW00)). |
|
|
|
map(point -> Math.abs(point.pos.y - Double.valueOf(tip_ref_01_01.pos.y)) / point.row.ordinal()).toList() |
|
|
|
); |
|
|
|
|
|
|
|
tip01_01_z += 3; |
|
|
|
|
|
|
|
tip000 = new Pos3d(tip01_01_x.intValue(), tip01_01_y.intValue(), tip01_01_z.intValue()); |
|
|
|
tipdx = dx; |
|
|
|
tipdy = dy; |
|
|
|
|
|
|
|
|
|
|
|
ObjectNode node = new ObjectMapper().createObjectNode(); |
|
|
|
node.put("tip000", ZJsonHelper.createObjectNode(tip000)); |
|
|
|
node.put("tipdx", tipdx); |
|
|
|
node.put("tipdy", tipdy); |
|
|
|
return node; |
|
|
|
@ExtApiFn(name = "步骤2.测量Tip119坐标", group = "测量Tip间距", order = 41) |
|
|
|
public void measuringTip119Pos() throws AppException { |
|
|
|
tip119Pos = measuringTipPos(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ExtApiFn(name = "保存计算结果", group = "辅助标定", order = 24) |
|
|
|
public void saveTipGroupPos() throws AppException { |
|
|
|
TipPosConfig tipPosConfig = getTipPosConfig(); |
|
|
|
if (tipdx == null || tipdx.isNaN() || tipdx.isInfinite()) { |
|
|
|
tipdx = tipPosConfig.spaceingX; |
|
|
|
@ExtApiFn(name = "步骤3.计算Tip间距", group = "测量Tip间距", order = 42) |
|
|
|
public Object computeDxAndDy() { |
|
|
|
if (tip000Pos == null || tip119Pos == null) { |
|
|
|
return "请先测量Tip000和Tip119坐标"; |
|
|
|
} |
|
|
|
|
|
|
|
if (tipdy == null || tipdy.isNaN() || tipdy.isInfinite()) { |
|
|
|
tipdy = tipPosConfig.spaceingY; |
|
|
|
} |
|
|
|
|
|
|
|
hbotTipPosMgr.setTipGroupParam(tipGroup, tip000, tipdx, tipdy); |
|
|
|
double dx = (tip119Pos.x - tip000Pos.x) / 11.0; |
|
|
|
double dy = (tip119Pos.y - tip000Pos.y) / 9.0; |
|
|
|
return Map.of("dx", dx, "dy", dy); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ExtApiFn(name = "获取当前Tip组的配置", group = "直接设置坐标", order = 31) |
|
|
|
public TipPosConfig getTipPosConfig() { |
|
|
|
@ExtApiFn(name = "获取配置", group = "设置", order = 100) |
|
|
|
public TipPosConfig getTipPosConfig(TipGroup tipGroup) { |
|
|
|
return hbotTipPosMgr.getTipPosCfg(tipGroup); |
|
|
|
} |
|
|
|
|
|
|
|
@ExtApiFn(name = "设置Tip000坐标", group = "直接设置坐标", order = 32) |
|
|
|
public void setTipPos000(Integer x, Integer y, Integer z) { |
|
|
|
tip000 = new Pos3d(x, y, z); |
|
|
|
@ExtApiFn(name = "设置Tip000坐标", group = "设置", order = 101) |
|
|
|
public void setTipPos000(TipGroup tipGroup, Integer x, Integer y, Integer z) { |
|
|
|
var tip000 = new Pos3d(x, y, z); |
|
|
|
TipPosConfig poscfg = hbotTipPosMgr.getTipPosCfg(tipGroup); |
|
|
|
poscfg.tip000 = tip000; |
|
|
|
hbotTipPosMgr.setTipPosCfg(tipGroup, poscfg); |
|
|
|
} |
|
|
|
|
|
|
|
@ExtApiFn(name = "设置Tip间距", group = "直接设置坐标", order = 33) |
|
|
|
public void setSpacingXAndSpacingY(Double spacingX, Double spacingY) { |
|
|
|
@ExtApiFn(name = "设置Tip间距", group = "设置", order = 102) |
|
|
|
public void setSpacingXAndSpacingY(TipGroup tipGroup, Double spacingX, Double spacingY) { |
|
|
|
TipPosConfig poscfg = hbotTipPosMgr.getTipPosCfg(tipGroup); |
|
|
|
poscfg.spaceingX = spacingX; |
|
|
|
poscfg.spaceingY = spacingY; |
|
|
@ -242,10 +163,6 @@ public class HbotTipPosCalibration { |
|
|
|
|
|
|
|
for (int i = 0; i < AppConstant.TIP_NUM; i++) { |
|
|
|
hbotCtrlService.testTakeTip(tipGroup, i); |
|
|
|
Pos3d tipPos = hbotConsumableParamMgr.getTipPos(tipGroup, i); |
|
|
|
TipRefPoint tipRefPoint = new TipRefPoint(TipRowNum.values()[i / 12], TipColumnNum.values()[i % 12], tipPos); |
|
|
|
if (tipRefPosList != null) |
|
|
|
tipRefPosList.add(tipRefPoint); |
|
|
|
if (checkStopFlag()) |
|
|
|
return; |
|
|
|
} |
|
|
@ -265,10 +182,6 @@ public class HbotTipPosCalibration { |
|
|
|
|
|
|
|
for (Integer i : testPoint) { |
|
|
|
hbotCtrlService.testTakeTip(tipGroup, i); |
|
|
|
Pos3d tipPos = hbotConsumableParamMgr.getTipPos(tipGroup, i); |
|
|
|
TipRefPoint tipRefPoint = new TipRefPoint(TipRowNum.values()[i / 12], TipColumnNum.values()[i % 12], tipPos); |
|
|
|
if (tipRefPosList != null) |
|
|
|
tipRefPosList.add(tipRefPoint); |
|
|
|
if (checkStopFlag()) |
|
|
|
return; |
|
|
|
} |
|
|
|