def go_to_bottom(): botcamloc = get_coords() if botcamloc is None: # cancel return noz = machine.getDefaultHead().getDefaultNozzle() if noz is None: return # should error # we don't want to go straight to the cam location--first XY, # then Z safeMoveLocation = Location(botcamloc.getUnits(), botcamloc.getX(), botcamloc.getY(), 0, 0); MovableUtils.moveToLocationAtSafeZ(noz, safeMoveLocation) #machine.defaultHead.defaultNozzle.moveTo(safeMoveLocation) # our default z will be whatever the camera says finalLocation = botcamloc.add(Location(botcamloc.getUnits(), 0,0, botcamloc.getZ(), 0)) ntip = noz.getNozzleTip() if ntip is not None: ntipcalib = ntip.getCalibration() if ntipcalib is not None and ntipcalib.isEnabled(): zoffset = ntipcalib.getCalibrationZOffset() if zoffset is not None: finalLocation = botcamloc.add(Location(zoffset.getUnits(), 0, 0, zoffset.getValue(), 0)) #print("WOULD LIKE TO MOVE TO %s" % str(finalLocation)) MovableUtils.moveToLocationAtSafeZ(noz, finalLocation)
def go_cam(): loc = get_coords() if loc is None: # cancel return if machine.defaultHead is None or machine.defaultHead.defaultCamera is None: return MovableUtils.moveToLocationAtSafeZ(machine.defaultHead.defaultCamera, loc)
def go_z(): nozzle = machine.defaultHead.defaultNozzle curloc = nozzle.location zval = psypnp.ui.getUserInputFloat("Go Z", curloc.z) if zval is None: # cancel return if zval > HardLimitMax or zval < HardLimitMin: machine.defaultHead.moveToSafeZ() psypnp.ui.showError("That's crazy talk ( %s < limits < %s) " % (str(HardLimitMin), str(HardLimitMax))) else: loc = Location(LengthUnit.Millimeters, curloc.x, curloc.y, zval, 0) #nozzle.moveTo(loc) MovableUtils.moveToLocationAtSafeZ(nozzle, loc)
def go_angle(): nozzle = machine.defaultHead.defaultNozzle curloc = nozzle.location val = psypnp.ui.getUserInputFloat("Go Rotation", curloc.rotation) if val is None: #cancel return if val < (-1 * HardMaxAngle) or val > HardMaxAngle: psypnp.ui.showError("Only angles <= abs(%s) supported" % str(HardMaxAngle)) return loc = Location(LengthUnit.Millimeters, curloc.x, curloc.y, curloc.z, val) # nozzle.moveTo(loc) MovableUtils.moveToLocationAtSafeZ(nozzle, loc)
def go_cam(): if machine.defaultHead is None: # too weird return # should error defNozz = machine.defaultHead.getDefaultNozzle() if defNozz is None: return # should error loc = get_coords(defNozz) if loc is None: # cancel return MovableUtils.moveToLocationAtSafeZ(defNozz, loc)
def check_feeder_heights(): global StorageParentName cur_feeder_index = get_current_idx() #next_feeder_index = get_next_feeder_index(cur_feeder_index) curFeed = get_current_feeder() if curFeed is None: return False if not curFeed.isEnabled(): # we may have a stale current index reset_idx_counter() psypnp.ui.showError("Stale feed index, have reset. Please go again.") return True #curFeed = get_next_feeder_from(next_feeder_index) feederPart = curFeed.getPart() print("Will move to feeder %i\n%s \nwith part \n%s " % (cur_feeder_index, str(curFeed.getName()), str(feederPart.getId()))) # always safeZ machine.defaultHead.moveToSafeZ() # we don't want to go straight to the cam location--first XY, # then Z feedPickLoc = curFeed.getPickLocation() safeMoveLocation = Location(feedPickLoc.getUnits(), feedPickLoc.getX(), feedPickLoc.getY(), 0, 45) MovableUtils.moveToLocationAtSafeZ(machine.defaultHead.defaultNozzle, safeMoveLocation) #print("WOULD MOVE FIRST TO: %s" % str(safeMoveLocation)) locDepthZ = feedPickLoc.getZ() if MinSaneHeightAbs > abs(locDepthZ): print("Something weird with this feed -- height is %s" % str(locDepthZ)) psypnp.ui.showError("Feeder height is strange: %s" % curFeed.getId()) return False # length "down" to bottom of feed pick location, e.g. -35.00 locDepthZLength = Length(locDepthZ, feedPickLoc.getUnits()) # height of part, this is how much above the bottom of the feed pick # location openpnp will travel before picking up partHeight = feederPart.getHeight() actualDepthZTravelled = locDepthZLength if DoSubtractPartHeightFromLevel: print("Removing part height from travel depth") actualDepthZTravelled = locDepthZLength.add(partHeight) # target location "real" depth openpnp will travel (as Location object) locRealDepth = Location(feedPickLoc.getUnits(), 0, 0, actualDepthZTravelled.getValue(), 0) # safe depth to travel to, basically real location depth + MinSaneHeightAbs (mm) locSafeDepth = locRealDepth.add( Location(LengthUnit.Millimeters, 0, 0, MinSaneHeightAbs, 45)) # our first stage move is the (x,y) "safe" location with safe motion down locDownFirstStage = safeMoveLocation.add(locSafeDepth) # go there now machine.defaultHead.defaultNozzle.moveTo(locDownFirstStage) #print("NOW MOVE TO: %s" % str(locDownFirstStage)) # now lets slow down curSpeed = machine.getSpeed() machine.setSpeed(0.25) #locFinalApproach = safeMoveLocation.add(locRealDepth) #locFinalApproach = feedPickLoc.subtract(locRealDepth)Location(feedPickLoc.getUnits(), 0, 0, actualDepthZTravelled.getValue(), 0) locFinalApproach = Location(feedPickLoc.getUnits(), feedPickLoc.getX(), feedPickLoc.getY(), actualDepthZTravelled.getValue(), feedPickLoc.getRotation()) #print("WILL FINALLY MOVE TO: %s" % str(locFinalApproach)) #print("ORIG FEEDPICK LOC: %s" % str(feedPickLoc)) machine.defaultHead.defaultNozzle.moveTo(locFinalApproach) machine.setSpeed(curSpeed) keepShowing = True while keepShowing: sel = psypnp.getOption("Result", "How does %s look?" % curFeed.getName(), [ 'Thrilled!', 'Set Height', 'Up 0.1', 'Down 0.1', 'Up 1', 'Down 1' ]) if sel is None: machine.defaultHead.moveToSafeZ() return False keepShowing = False if sel == 0: # all good increment_idx_counter(cur_feeder_index) machine.defaultHead.moveToSafeZ() return True if sel == 1: # calculate height based on this # take the part height and call the feeder that much lower nozLoc = machine.defaultHead.defaultNozzle.location nozHeight = Length(nozLoc.getZ(), nozLoc.getUnits()) feederHeight = nozHeight if DoSubtractPartHeightFromLevel: print("Adding part height to travel depth") feederHeight = nozHeight.subtract(partHeight) # now get the reference hole location refHole = curFeed.getReferenceHoleLocation() # create a new hole without a Z newHole = Location(refHole.getUnits(), refHole.getX(), refHole.getY(), 0, refHole.getRotation()) # finally, add the feederHeight we determined #newHeight = nozLoc.getZ() newZLoc = Location(feederHeight.getUnits(), 0, 0, feederHeight.getValue(), 0) newHole = newHole.add(newZLoc) #print("WILL Set ref hole for %s to %s" % (feederPart.getName(), str(newHole))) curFeed.setReferenceHoleLocation(newHole) machine.defaultHead.moveToSafeZ() increment_idx_counter(cur_feeder_index) return True if sel == 2: # Up 0.1 feedPickLoc = feedPickLoc.add( Location(LengthUnit.Millimeters, 0, 0, 0.1, 0)) machine.defaultHead.defaultNozzle.moveTo(feedPickLoc) keepShowing = True if sel == 3: # Down 0.1 feedPickLoc = feedPickLoc.subtract( Location(LengthUnit.Millimeters, 0, 0, 0.1, 0)) machine.defaultHead.defaultNozzle.moveTo(feedPickLoc) keepShowing = True if sel == 4: # Up 1 feedPickLoc = feedPickLoc.add( Location(LengthUnit.Millimeters, 0, 0, 1, 0)) machine.defaultHead.defaultNozzle.moveTo(feedPickLoc) keepShowing = True if sel == 5: # Down 1 feedPickLoc = feedPickLoc.subtract( Location(LengthUnit.Millimeters, 0, 0, 1, 0)) machine.defaultHead.defaultNozzle.moveTo(feedPickLoc) keepShowing = True return False
def go_cam(): cam = machine.defaultHead.defaultCamera location = Location(LengthUnit.Millimeters, 0, 0, 0, 0) MovableUtils.moveToLocationAtSafeZ(cam, location)