//move to safe height
nozzle.moveToSafeZ(1.0);
//create local variables
Location visionX0Offset;
Location visionX180Offset;
Location visionY90Offset;
Location visionY270Offset;
Location newNozzleOffsets = this.nozzleOffsets;
Location mirrorStartLocation = this.mirrorStartLocation;
Location mirrorMidLocation = this.mirrorMidLocation;
Location mirrorEndLocation = this.mirrorEndLocation;
Location Xoffset;
Location Yoffset;
double Zoffset;
//do camera magic
Head head = nozzle.getHead();
// Find the Camera to be used for vision
Camera camera = null;
for (Camera c : head.getCameras()) {
if (c.getVisionProvider() != null) {
camera = c;
}
}
if (camera == null) {
throw new Exception("No vision capable camera found on head.");
}
// Position the camera over the pick location.
logger.debug("Move camera to mirror location.");
//move to mirror position
camera.moveTo(mirrorStartLocation, 1.0);
camera.moveTo(mirrorMidLocation, 1.0);
camera.moveTo(mirrorEndLocation, 1.0);
//do camera magic
visionX0Offset = visionMgr.getVisionOffsets(head, mirrorEndLocation.derive(null, null, null, 0.0),vision);
visionY90Offset = visionMgr.getVisionOffsets(head, mirrorEndLocation.derive(null, null, null, 90.0),vision);
visionX180Offset = visionMgr.getVisionOffsets(head, mirrorEndLocation.derive(null, null, null, 180.0),vision);
visionY270Offset = visionMgr.getVisionOffsets(head, mirrorEndLocation.derive(null, null, null, 270.0),vision);
Xoffset = visionX180Offset.subtract(visionX0Offset);
Yoffset = visionY90Offset.subtract(visionY270Offset);
// Zoffset = visionX0Offset.getY();
Zoffset = 0.0; //TODO: fix Z offset
//move away from mirror position
camera.moveTo(mirrorEndLocation, 1.0);
camera.moveTo(mirrorMidLocation, 1.0);
camera.moveTo(mirrorStartLocation, 1.0);
double offsetX = Xoffset.getX()/2;
double offsetY = Yoffset.getX()/2;
offsetX *= this.pixelComp; //compensate for calibration distance being different than pick distance
offsetY *= this.pixelComp; //TODO: make this more elegant and configurable
logger.debug("final nozzletip calibration, at angle zero, offsetX {}, offsetY {}", offsetX, offsetY);