示例#1
0
 @Override
 public String toString() {
   return "Place " + nozzle + " " + nozzle.getNozzleTip().getName();
 }
  @Override
  public void feed(Nozzle nozzle) throws Exception {
    logger.debug("feed({})", nozzle);

    if (actuatorName == null) {
      throw new Exception("No actuator name set.");
    }

    Head head = nozzle.getHead();

    /*
     * TODO: We can optimize the feed process:
     * If we are already higher than the Z we will move to to index plus
     * the height of the tape, we don't need to Safe Z first.
     * There is also probably no reason to Safe Z after extracting the
     * pin since if the tool was going to hit it would have already hit.
     */

    Actuator actuator = head.getActuatorByName(actuatorName);

    if (actuator == null) {
      throw new Exception(
          String.format(
              "No Actuator found with name %s on feed Head %s", actuatorName, head.getName()));
    }

    head.moveToSafeZ(1.0);

    if (vision.isEnabled()) {
      if (visionOffset == null) {
        // This is the first feed with vision, or the offset has
        // been invalidated for some reason. We need to get an offset,
        // complete the feed operation and then get a new offset
        // for the next operation. By front loading this we make sure
        // that all future calls can go directly to the feed operation
        // and skip checking the vision first.
        logger.debug("First feed, running vision pre-flight.");

        visionOffset = getVisionOffsets(head, location);
      }
      logger.debug("visionOffsets " + visionOffset);
    }

    // Now we have visionOffsets (if we're using them) so we
    // need to create a local, offset version of the feedStartLocation,
    // feedEndLocation and pickLocation. pickLocation will be saved
    // for the pick operation while feed start and end are used
    // here and then discarded.
    Location feedStartLocation = this.feedStartLocation;
    Location feedEndLocation = this.feedEndLocation;
    pickLocation = this.location;
    if (visionOffset != null) {
      feedStartLocation = feedStartLocation.subtract(visionOffset);
      feedEndLocation = feedEndLocation.subtract(visionOffset);
      pickLocation = pickLocation.subtract(visionOffset);
    }

    // Move the actuator to the feed start location.
    actuator.moveTo(feedStartLocation.derive(null, null, Double.NaN, Double.NaN), 1.0);

    // extend the pin
    actuator.actuate(true);

    // insert the pin
    actuator.moveTo(feedStartLocation, 1.0);

    // drag the tape
    actuator.moveTo(feedEndLocation, feedSpeed);

    head.moveToSafeZ(1.0);

    // retract the pin
    actuator.actuate(false);

    if (vision.isEnabled()) {
      visionOffset = getVisionOffsets(head, location);

      logger.debug("final visionOffsets " + visionOffset);
    }

    logger.debug("Modified pickLocation {}", pickLocation);
  }