Package org.openpnp.model

Examples of org.openpnp.model.Location


  public void updateDros() {
    if (selectedNozzle == null) {
      return;
    }
   
    Location l = selectedNozzle.getLocation();
    l = l.convertToUnits(configuration.getSystemUnits());
   
    double x, y, z, c;
   
    x = l.getX();
    y = l.getY();
    z = l.getZ();
    c = l.getRotation();
   
   
    if (!textFieldX.hasFocus()) {
      textFieldX.setText(String.format(configuration.getLengthDisplayFormat(), x));
    }
View Full Code Here


                Nozzle nozzle = solution.nozzle;
                NozzleTip nozzleTip = solution.nozzleTip;
               
                firePartProcessingStarted(solution.boardLocation, solution.placement);
       
                Location placementLocation =
                        Utils2D.calculateBoardPlacementLocation(bl, placement);

        // Update the placementLocation with the proper Z value. This is
        // the distance to the top of the board plus the height of
        // the part.
                Location boardLocation = bl.getLocation().convertToUnits(placementLocation.getUnits());
        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;
              }
        }
        // End NozzleTip Changer
       
        if (!nozzle.getNozzleTip().canHandle(part)) {
                    fireJobEncounteredError(JobError.PickError, "Selected nozzle tip is not compatible with part");
                    return;
        }
       
        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);
            }
    }
   
    fireDetailedStatusUpdated("Job complete.");
View Full Code Here

            return false;
        }
       
        // Now that the Feeder has done it's feed operation we can get
        // the pick location from it.
        Location pickLocation;
        try {
            pickLocation = feeder.getPickLocation();
        }
        catch (Exception e) {
            fireJobEncounteredError(JobError.FeederError, e.getMessage());
            return false;
        }

        fireDetailedStatusUpdated(String.format("Move to safe Z at (%s).", nozzle.getLocation()));
       
        if (!shouldJobProcessingContinue()) {
            return false;
        }

        try {
            nozzle.moveToSafeZ(1.0);
        }
        catch (Exception e) {
            fireJobEncounteredError(JobError.MachineMovementError, e.getMessage());
            return false;
        }

        fireDetailedStatusUpdated(String.format("Move to pick location, safe Z at (%s).", pickLocation));

        if (!shouldJobProcessingContinue()) {
            return false;
        }
       
        // Move the Nozzle to the pick Location at safe Z
        try {
            nozzle.moveTo(pickLocation.derive(null, null, Double.NaN, null), 1.0);
        }
        catch (Exception e) {
            fireJobEncounteredError(JobError.MachineMovementError, e.getMessage());
            return false;
        }
View Full Code Here

    }

    @Override
    public void moveToSafeZ(double speed) throws Exception {
    logger.debug("{}.moveToSafeZ({})", new Object[]{getId(), speed});
        Location l = new Location(getLocation().getUnits(), Double.NaN,
                Double.NaN, 0, Double.NaN);
        driver.moveTo(this, l, speed);
        machine.fireMachineHeadActivity(head);
    }
View Full Code Here

      double width = Math.abs(endX - startX);
      double height = Math.abs(endY - startY);
      // Determine how many images are needed
      BufferedImage image = camera.capture();
      // Figure out how many units per image we are getting
      Location unitsPerPixel = camera.getUnitsPerPixel();
      unitsPerPixel = unitsPerPixel.convertToUnits(Configuration.get().getSystemUnits());
      double imageWidthInUnits = unitsPerPixel.getX() * image.getWidth();
      double imageHeightInUnits = unitsPerPixel.getY() * image.getHeight();
      logger.info(String.format("Images are %d, %d pixels, %2.3f, %2.3f %s",
          image.getWidth(),
          image.getHeight(),
          imageWidthInUnits,
          imageHeightInUnits,
          unitsPerPixel.getUnits().getShortName()));
      int widthInImages = (int) (width / (imageWidthInUnits / 2));
      int heightInImages = (int) (height / (imageHeightInUnits / 2));
      int totalImages = (widthInImages * heightInImages);
      logger.info(String.format("Need to capture %d x %d images for a total of %d",
          widthInImages,
          heightInImages,
          totalImages));
      // Start loop, checking for cancelled
      File outputDirectory = new File(txtOutputDirectory.getText());
      if (!outputDirectory.exists()) {
        throw new Exception("Output directory does not exist.");
      }
      if (startX >= endX) {
        throw new Exception("End Position X must be greater than End Position X");
      }
      if (startY >= endY) {
        throw new Exception("End Position Y must be greater than End Position Y");
      }
      progressBar.setMinimum(0);
      progressBar.setMaximum(totalImages - 1);
      progressBar.setValue(0);
      int currentImageX = 0, currentImageY = 0, currentImage = 0;
      while (!cancelled) {
          Location location = camera.getLocation();
          location = location.derive(
                  startX + ((imageWidthInUnits / 2) * currentImageX),
                  startY + ((imageHeightInUnits / 2) * currentImageY),
                  null,
                  null);
          camera.moveTo(location, 1.0);
        // Give the head and camera 500ms to settle
        Thread.sleep(500);
        // We capture two images to make sure that the one we save is
        // not coming from a previous frame.
        image = camera.capture();
        image = camera.capture();
        File outputFile = new File(outputDirectory,
            String.format(Locale.US, "%2.3f,%2.3f.png", location.getX(), location.getY()));
        ImageIO.write(image, "png",outputFile);
        progressBar.setValue(currentImage);
        currentImage++;
        currentImageX++;
        if (currentImageX == widthInImages) {
View Full Code Here

            .getLogger(ZippyNozzle.class);
   
    private Location appliedOffset;
   
    public ZippyNozzle(){
      appliedOffset = new Location(LengthUnit.Millimeters,0.0,0.0,0.0,0.0);     
    }
View Full Code Here

   
    @Override
    public void moveTo(Location location, double speed) throws Exception {
      ZippyNozzleTip nozzleTip = (ZippyNozzleTip) getNozzleTip();
       
      Location calculatedOffset; //new calculated offset
      Location adjustedLocation; //compensated location
     
      // pull calculated offsets for new location
      calculatedOffset = nozzleTip.calculateOffset(location);
     
    //each time, add in applied offsets, then subtract out new offset
      //this way if rotation doesn't change applied offset and calculated offset cancel out
    adjustedLocation = location.add(appliedOffset);
    adjustedLocation = location.subtract(calculatedOffset);
   
        //don't compensate if it would move past zero
        if(adjustedLocation.getX()>0.0 && adjustedLocation.getY()>0.0){
          //above zero, so call super to move to corrected position
          super.moveTo(adjustedLocation, speed);
          appliedOffset = calculatedOffset;
          logger.debug("{}.moveTo(adjusted {}, original {},  {})", new Object[] { id, adjustedLocation, location, speed } );
         
View Full Code Here

    }
   
    @Override
    public void moveToSafeZ(double speed) throws Exception {
    logger.debug("{}.moveToSafeZ({})", new Object[]{getId(), speed});
        Location l = new Location(getLocation().getUnits(), Double.NaN, Double.NaN, 10, Double.NaN);
        driver.moveTo(this, l, speed);
        machine.fireMachineHeadActivity(head);
    }
View Full Code Here

    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());
      return;
View Full Code Here

   * from a perfectly strait nozzle at 0 degrees. These offsets are used
   * to compensate for nozzle crookedness when moving and rotating the nozzle tip
   */
    public Location calculateOffset(Location location){
     
      Location ntOffset = this.nozzleOffsets; //nozzle tip offset from xml file
      Location calculatedOffset = null; //new calculated offset


      // Create the point that represents the nozzle tip offsets (stored offset always for angle zero)
    Point nt_p = new Point(ntOffset.getX(), ntOffset.getY());

View Full Code Here

TOP

Related Classes of org.openpnp.model.Location

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.