Package org.openpnp.model

Examples of org.openpnp.model.Location


    return new Point(point.getX() * scaleX, point.getY() * scaleY);
  }
 
  public static Location calculateBoardPlacementLocation(BoardLocation bl, Placement placement) {
        // 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);
       
        return placementLocation;
     
  }
View Full Code Here


        actualB = actualB.convertToUnits(idealA.getUnits());

        double angle = Math.toDegrees(Math.atan2(actualA.getY() - actualB.getY(), actualA.getX() - actualB.getX())
                - Math.atan2(idealA.getY() - idealB.getY(), idealA.getX() - idealB.getX()));
       
        Location idealARotated = idealA.rotateXy(angle);
       
        Location offset = actualA.subtract(idealARotated);
       
        return new Location(idealA.getUnits(), offset.getX(), offset.getY(), 0, angle);
    }
View Full Code Here

      double placementY = Double.parseDouble(matcher.group(5));
      double placementRotation = Double.parseDouble(matcher.group(6));
      String placementLayer = matcher.group(7);
     
      Placement placement = new Placement(placementId);
      placement.setLocation(new Location(
              LengthUnit.Millimeters,
              placementX,
              placementY,
              0,
              placementRotation));
View Full Code Here

  private void jog(final int x, final int y, final int z, final int c) {
    machineControlsPanel.submitMachineTask(new Runnable() {
      public void run() {
        try {
            Location l = machineControlsPanel.getSelectedNozzle().getLocation().convertToUnits(Configuration.get().getSystemUnits());
          double xPos = l.getX();
          double yPos = l.getY();
          double zPos = l.getZ();
          double cPos = l.getRotation();

          double jogIncrement = new Length(machineControlsPanel
              .getJogIncrement(), configuration.getSystemUnits())
              .getValue();

          if (x > 0) {
            xPos += jogIncrement;
          }
          else if (x < 0) {
            xPos -= jogIncrement;
          }

          if (y > 0) {
            yPos += jogIncrement;
          }
          else if (y < 0) {
            yPos -= jogIncrement;
          }

          if (z > 0) {
            zPos += jogIncrement;
          }
          else if (z < 0) {
            zPos -= jogIncrement;
          }

          if (c > 0) {
            cPos -= jogIncrement;
          }
          else if (c < 0) {
            cPos += jogIncrement;
          }
         
          machineControlsPanel.getSelectedNozzle().moveTo(new Location(l.getUnits(), xPos, yPos, zPos, cPos), 1.0);
        }
        catch (Exception e) {
          MessageBoxes.errorBox(frame, "Jog Failed", e.getMessage());
        }
      }
View Full Code Here

      Pattern pattern = Pattern.compile("(\\S+)\\s+(\\d+\\.\\d+)\\s+(\\d+\\.\\d+)\\s+(\\d{1,3})\\s(.*?)\\s(.*)");
      Matcher matcher = pattern.matcher(line);
      matcher.matches();
      Placement placement = new Placement(matcher.group(1));
      placement.setLocation(new Location(
              LengthUnit.Millimeters,
              Double.parseDouble(matcher.group(2)),
              Double.parseDouble(matcher.group(3)),
              0,
              Double.parseDouble(matcher.group(4))));
View Full Code Here

        Head h1 = machine.getHead("H1");
        Nozzle n1 = h1.getNozzle("N1");
        Nozzle n2 = h1.getNozzle("N2");

        delegate.expectMove("Move N1 to F1", n1, new Location(LengthUnit.Millimeters, -10, 0, 0, 0), 1.0);
        delegate.expectPick(n1);
       
        delegate.expectMove("Move N2 to F1", n2, new Location(LengthUnit.Millimeters, -20, 0, 0, 0), 1.0);
        delegate.expectPick(n2);
       
        delegate.expectMove("Move N1 to R1, Safe-Z", n1, new Location(LengthUnit.Millimeters, 0, 10, 0, 45), 1.0);
        delegate.expectMove("Move N1 to R1, Z", n1, new Location(LengthUnit.Millimeters, 0, 10, 0.825500, 45), 1.0);
        delegate.expectPlace(n1);
        delegate.expectMove("Move N1 to R1, Safe-Z", n1, new Location(LengthUnit.Millimeters, 0, 10, 0, 45), 1.0);
       
        delegate.expectMove("Move N2 to R2, Safe-Z", n2, new Location(LengthUnit.Millimeters, 00, 20, 0, 90), 1.0);
        delegate.expectMove("Move N2 to R2, Z", n2, new Location(LengthUnit.Millimeters, 00, 20, 0.825500, 90), 1.0);
        delegate.expectPlace(n2);
        delegate.expectMove("Move N2 to R2, Safe-Z", n2, new Location(LengthUnit.Millimeters, 00, 20, 0, 90), 1.0);
       
        jobProcessor.load(job);
        machine.setEnabled(true);
        synchronized (notifier) {
            jobProcessor.start();
View Full Code Here

                Side.Top));
        board.addPlacement(createPlacement("R2", "R-0805-10K", 20, 20, 0, 90,
                Side.Top));

        BoardLocation boardLocation = new BoardLocation(board);
        boardLocation.setLocation(new Location(LengthUnit.Millimeters, 0, 0, 0,
                0));
        boardLocation.setSide(Side.Top);

        job.addBoardLocation(boardLocation);
View Full Code Here

    public static Placement createPlacement(String id, String partId, double x,
            double y, double z, double rotation, Side side) {
        Placement placement = new Placement(id);
        placement.setPart(Configuration.get().getPart(partId));
        placement.setLocation(new Location(LengthUnit.Millimeters, x, y, z,
                rotation));
        placement.setSide(side);
        return placement;
    }
View Full Code Here

public class Utils2DTest {
    @Test
    public void testCalculateAngleAndOffset() throws Exception {
        // Create two placements to test with.
        Location idealA = new Location(LengthUnit.Millimeters, 5, 35, 0, 0);
        Location idealB = new Location(LengthUnit.Millimeters, 55, 5, 0, 0);
       
        // Rotate and translate the placements to simulate a board that has
        // been placed on the table
        double angle = 10;
        Location offset = new Location(idealA.getUnits(), 10, 10, 0, 0);
       
        Location actualA = idealA.rotateXy(angle);
        actualA = actualA.add(offset);
        Location actualB = idealB.rotateXy(angle);
        actualB = actualB.add(offset);
       
        System.out.println("idealA " + idealA);
        System.out.println("idealB " + idealB);
        System.out.println("actualA " + actualA);
        System.out.println("actualB " + actualB);
       
        Location results = Utils2D.calculateAngleAndOffset(idealA, idealB, actualA, actualB);
       
        System.out.println("results " + results);
       
        within("angle", results.getRotation(), angle, 0.001);
        within("x", results.getX(), offset.getX(), 0.01);
        within("y", results.getY(), offset.getY(), 0.01);
    }
View Full Code Here

    }

    @Override
    public void home(ReferenceHead head) throws Exception {
        logger.debug("home()");
        location = new Location(LengthUnit.Millimeters, 0, 0, 0, 0);
        delegate.home(head);
    }
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.