Package org.openpnp.spi

Examples of org.openpnp.spi.Head


  @Override
  protected void preProcessJob(Machine machine) {
    Set<PlacementSolution> solutions;
//    Machine machine = configuration.getMachine();
    Head head = machine.getHeads().get(0);
    JobPlanner jobPlanner = machine.getJobPlanner();

    for (BoardLocation jobBoard : job.getBoardLocations()) {
      Board board = jobBoard.getBoard();
     
View Full Code Here


 
  @Override
  public void run() {
    Set<PlacementSolution> solutions;
    Machine machine = Configuration.get().getMachine();
    Head head = machine.getHeads().get(0);
    JobPlanner jobPlanner = machine.getJobPlanner();

    //pre job stuff
    state = JobState.Running;
    fireJobStateChanged();
    try {
      head.home();
      Nozzle nozzle = head.getNozzles().get(0);
      Location l = new Location(LengthUnit.Millimeters, 5.0, 20.0, 1.0, 0.0);
      nozzle.moveTo(l, 1.0);
    }
    catch (Exception e) {
      fireJobEncounteredError(JobError.MachineMovementError, e.getMessage());
      return;
    }
   
   
    //pre-test for we have feeders, etc
    preProcessJob(machine);
    jobPlanner.setJob(job);
       
    while ((solutions = jobPlanner.getNextPlacementSolutions(head)) != null) {
        LinkedHashMap<PlacementSolution, Location> placementSolutionLocations = new LinkedHashMap<PlacementSolution, Location>();
        for (PlacementSolution solution : solutions) {
        firePartProcessingStarted(solution.boardLocation, solution.placement);
       
        BoardLocation bl = solution.boardLocation;
        Part part = solution.placement.getPart();
        Feeder feeder = solution.feeder;
        Placement placement = solution.placement;
        Nozzle nozzle = solution.nozzle;
        NozzleTip nozzleTip = solution.nozzleTip;

        // Determine where we will place the part
        Location boardLocation = bl.getLocation();
        Location placementLocation = placement.getLocation();

        // We will work in the units of the placementLocation, so convert
        // anything that isn't in those units to it.
        boardLocation = boardLocation.convertToUnits(placementLocation.getUnits());
       
        // If we are placing the bottom of the board we need to invert
        // the placement location.
        if (bl.getSide() == Side.Bottom) {
          placementLocation = placementLocation.invert(true, false, false, false);
        }

        // Create the point that represents the final placement location
        Point p = new Point(placementLocation.getX(),
            placementLocation.getY());

        // Rotate and translate the point into the same coordinate space
        // as the board
        p = Utils2D.rotateTranslateScalePoint(p, boardLocation
            .getRotation(), boardLocation.getX(), boardLocation
            .getY(), 1.0, 1.0);

        // Update the placementLocation with the transformed point
        placementLocation = placementLocation.derive(p.getX(), p.getY(), null, null);

        // Update the placementLocation with the board's rotation and
        // the placement's rotation
        // This sets the rotation of the part itself when it will be
        // placed
        placementLocation = placementLocation.derive(
                null,
                null,
                null,
                (placementLocation.getRotation() + boardLocation.getRotation()) % 360.0);

        // Update the placementLocation with the proper Z value. This is
        // the distance to the top of the board minus the height of
        // the part.
        double partHeight = part.getHeight().convertToUnits(placementLocation.getUnits()).getValue();
        placementLocation = placementLocation.derive(null, null, boardLocation.getZ() - partHeight, null);


       
                // NozzleTip Changer
                if (nozzle.getNozzleTip() != nozzleTip) {
                    fireDetailedStatusUpdated(String.format("Unload nozzle tip from nozzle %s.", nozzle.getId()));       

                    if (!shouldJobProcessingContinue()) {
                        return;
                    }
                   
                    try {
                        nozzle.unloadNozzleTip();
                    }
                    catch (Exception e) {
                        fireJobEncounteredError(JobError.PickError, e.getMessage());
                        return;
                    }
                   
                    fireDetailedStatusUpdated(String.format("Load nozzle tip %s into nozzle %s.", nozzleTip.getId(), nozzle.getId()));       

                    if (!shouldJobProcessingContinue()) {
                        return;
                    }
                                       
                    try {
                        nozzle.loadNozzleTip(nozzleTip);
                    }
                    catch (Exception e) {
                        fireJobEncounteredError(JobError.PickError, e.getMessage());
                        return;
                    }
                   
                    if (nozzle.getNozzleTip() != nozzleTip) {
                        fireJobEncounteredError(JobError.PickError, "Failed to load correct nozzle tip");
                        return;
                    }
                   
                    try {
                        ((ZippyNozzleTip) nozzleTip).calibrate((ZippyNozzle) nozzle);                   
                    }
                    catch (Exception e) {
                        fireJobEncounteredError(JobError.PickError, e.getMessage());
                        return;
                    }
                }
                // End NozzleTip Changer
               
                if (!nozzle.getNozzleTip().canHandle(part)) {
                    fireJobEncounteredError(JobError.PickError, "Selected nozzle tip is not compatible with part");
                }
               
        pick(nozzle, feeder, bl, placement);
        placementSolutionLocations.put(solution, placementLocation);
      }
       
            // TODO: a lot of the event fires are broken
        for (PlacementSolution solution : solutions) {
                Nozzle nozzle = solution.nozzle;
                BoardLocation bl = solution.boardLocation;
                Placement placement = solution.placement;
                Location placementLocation = placementSolutionLocations.get(solution);
                place(nozzle, bl, placementLocation, placement);
            }
       
    }
    //post job clean up
    state = JobState.Stopped;
    fireJobStateChanged();
    //park
    try {
      head.home();
      Nozzle nozzle = head.getNozzles().get(0);
      Location l = new Location(LengthUnit.Millimeters, 0.0, 0.0, 8.5, 0.0);
      nozzle.moveTo(l, 1.0);
    }
    catch (Exception e) {
      fireJobEncounteredError(JobError.MachineMovementError, e.getMessage());
View Full Code Here

    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;
      }
    }
   
View Full Code Here

    if (actuatorId == null) {
      throw new Exception("No actuator ID 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.getActuator(actuatorId);
   
    if (actuator == null) {
      throw new Exception(String.format("No Actuator found with ID %s on feed Head %s", actuatorId, head.getId()));
    }
   
    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()) {
View Full Code Here

  public boolean isCellEditable(int rowIndex, int columnIndex) {
    return false;
  }
 
  public Object getValueAt(int row, int col) {
    Head head = heads.get(row);
    switch (col) {
    case 0:
      return head.getId();
    case 1:
      return head.getClass().getSimpleName();
    default:
      return null;
    }
  }
View Full Code Here

TOP

Related Classes of org.openpnp.spi.Head

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.