Package org.openpnp.model

Examples of org.openpnp.model.Location


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


  private Thread thread;
  private URL sourceUrl;
  private File cacheDirectory;
 
  public TableScannerCamera() {
      unitsPerPixel = new Location(LengthUnit.Inches, 0.031, 0.031, 0, 0);
      sourceUri = "http://openpnp.org/downloads/tablescan/1/";
  }
View Full Code Here

      return null;
    }
    synchronized (buffer) {
      // Grab these values only once since the head may continue to move
      // while we are rendering.
      Location l = getLocation().convertToUnits(LengthUnit.Millimeters);
      double headX = l.getX();
      double headY = l.getY();
     
      /*
       * If the head position has not changed we don't need to re-render.
       * TODO: Doesn't that mean we can skip everything below
       * this block aside from on the first render, too?
       */
      if (lastX != headX || lastY != headY) {
         
        // Find the closest tile to the head's current position.
        Tile closestTile = getClosestTile(headX, headY);
        logger.debug("closestTile {}", closestTile);
       
        // If it has changed we need to render the entire buffer.
        if (closestTile != lastCenterTile) {
          lastCenterTile = closestTile;
          renderBuffer();
        }
       
        // And remember the last position we rendered.
        lastX = headX;
        lastY = headY;
      }
     
     
      /*
       * Get the distance from the center tile to the point we need to render.
       * TODO: Had to invert these from experimentation. Need to figure out
       * why and maybe make it configurable. I was too tired to figure it out.
       */
      double unitsDeltaX = headX - lastCenterTile.getX();
      double unitsDeltaY = lastCenterTile.getY() - headY;
     
      /*
       * Get the distance in pixels from the center tile to the head.
       */
            Location unitsPerPixel = getUnitsPerPixel().convertToUnits(LengthUnit.Millimeters);
      double deltaX = unitsDeltaX / unitsPerPixel.getX();
      double deltaY = unitsDeltaY / unitsPerPixel.getY();
     
      /*
       * Get the position within the buffer of the top left pixel of the
       * frame sized chunk we'll grab.
       */
 
View Full Code Here

  private BufferedImage source;
 
  private Thread thread;
 
  public ImageCamera() {
      unitsPerPixel = new Location(LengthUnit.Inches, 0.031, 0.031, 0, 0);
  }
View Full Code Here

                height,
                BufferedImage.TYPE_INT_ARGB);

        Graphics gFrame = frame.getGraphics();
       
        Location location = getLocation();
        double x = -location.getX();
        double y = location.getY();

        x /= getUnitsPerPixel().getX();
        y /= getUnitsPerPixel().getY();
       
        gFrame.drawImage(source, (int) (x + (width / 2)), (int) (y + (height / 2) - source.getHeight()), null);
View Full Code Here

     *
     * @param head
     * @return
     */
    protected Location getHeadLocation(Head head) {
        Location l = headLocations.get(head);
        if (l == null) {
            l = new Location(LengthUnit.Millimeters, 0, 0, 0, 0);
            setHeadLocation(head, l);
        }
        return l;
    }
View Full Code Here

        // Convert the Location to millimeters, since that's the unit that
        // this driver works in natively.
        location = location.convertToUnits(LengthUnit.Millimeters);

        // Get the current location of the Head that we'll move
        Location hl = getHeadLocation(hm.getHead());
       
        if (feedRateMmPerMinute > 0) {
            simulateMovement(hm, location, hl, speed);
        }
       
        // Now that movement is complete, update the stored Location to the new
        // Location, unless the incoming Location specified an axis with a value
        // of NaN. NaN is interpreted to mean "Don't move this axis" so we don't
        // update the value, either.

        hl = hl.derive(
                Double.isNaN(location.getX()) ? null : location.getX(),
                Double.isNaN(location.getY()) ? null : location.getY(),
                Double.isNaN(location.getZ()) ? null : location.getZ(),
                Double.isNaN(location.getRotation()) ? null : location.getRotation());
View Full Code Here

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

    offsetY *= -1;
   
        logger.debug("negated offsetX {}, offsetY {}", offsetX, offsetY);
   
    // And convert pixels to units
    Location unitsPerPixel = camera.getUnitsPerPixel();
    offsetX *= unitsPerPixel.getX();
    offsetY *= unitsPerPixel.getY();

        logger.debug("final, in camera units offsetX {}, offsetY {}", offsetX, offsetY);
   
        return new Location(unitsPerPixel.getUnits(), offsetX, offsetY, 0, 0);
  }
View Full Code Here

        }
    }

    @Override
    public Location getLocation(ReferenceHeadMountable hm) {
        return new Location(LengthUnit.Millimeters, x, y, z, c).add(hm.getHeadOffsets());
    }
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.