def probe_instrument(instrument, robot, tip_length=None) -> Point: robot.home() tp = robot.config.tip_probe if tip_length is None: tip_length = robot.config.tip_length[instrument.model] instrument._add_tip(tip_length) # probe_center is the point at the center of the switch pcb center = Point(*tp.center) hot_spots = robot_configs.calculate_tip_probe_hotspots(tip_length, tp) # The saved axis positions from limit switch response axis_pos = [] safe_height = _calculate_safeheight(robot, tp.z_clearance.crossover) log.info("Moving to safe z: {}".format(safe_height)) robot.poses = instrument._move(robot.poses, z=safe_height) for hs in hot_spots: x0 = tp.center[0] + hs.x_start_offs y0 = tp.center[1] + hs.y_start_offs z0 = hs.z_start_abs log.info("Moving to {}".format((x0, y0, z0))) robot.poses = instrument._move(robot.poses, x=x0, y=y0) robot.poses = instrument._move(robot.poses, z=z0) axis_index = 'xyz'.index(hs.axis) robot.poses = instrument._probe(robot.poses, hs.axis, hs.probe_distance) # Tip position is stored in accumulator and averaged for each axis # to be used for more accurate positioning for the next axis value = absolute(robot.poses, instrument)[axis_index] axis_pos.append(value) # after probing two points along the same axis # average them out, update center and clear accumulator # except Z, we're only probing that once if hs.axis == 'z': center = center._replace(**{hs.axis: axis_pos[0]}) axis_pos.clear() elif len(axis_pos) == 2: center = center._replace( **{hs.axis: (axis_pos[0] + axis_pos[1]) / 2.0}) axis_pos.clear() log.debug("Current axis positions for {}: {}".format( hs.axis, axis_pos)) # Bounce back to release end stop sgn = hs.probe_distance / abs(hs.probe_distance) bounce = value + (tp.bounce_distance * -sgn) robot.poses = instrument._move(robot.poses, **{hs.axis: bounce}) robot.poses = instrument._move(robot.poses, z=safe_height) log.debug("Updated center point tip probe {}".format(center)) instrument._remove_tip(tip_length) return center
def probe_instrument(instrument, robot, tip_length=None) -> Point: robot.home() if tip_length is None: tip_length = robot.config.tip_length[instrument.name] instrument._add_tip(tip_length) # probe_center is the point at the center of the switch pcb center = Point(*robot.config.probe_center) hot_spots = _calculate_hotspots(robot, tip_length, SWITCH_CLEARANCE, X_SWITCH_OFFSET_MM, Y_SWITCH_OFFSET_MM, Z_SWITCH_OFFSET_MM, Z_DECK_CLEARANCE, Z_PROBE_CLEARANCE, Z_PROBE_START_CLEARANCE) # The saved axis positions from limit switch response axis_pos = [] safe_height = _calculate_safeheight(robot, Z_CROSSOVER_CLEARANCE) log.info("Moving to safe z: {}".format(safe_height)) robot.poses = instrument._move(robot.poses, z=safe_height) for axis, x, y, z, distance in hot_spots: if axis == 'z': x = x + center.x y = y + center.y z = z + center.z else: x = x + center.x y = y + center.y log.info("Moving to {}".format((x, y, z))) robot.poses = instrument._move(robot.poses, x=x, y=y) robot.poses = instrument._move(robot.poses, z=z) axis_index = 'xyz'.index(axis) robot.poses = instrument._probe(robot.poses, axis, distance) # Tip position is stored in accumulator and averaged for each axis # to be used for more accurate positioning for the next axis value = absolute(robot.poses, instrument)[axis_index] axis_pos.append(value) # after probing two points along the same axis # average them out, update center and clear accumulator # except Z, we're only probing that once if axis == 'z': center = center._replace(**{axis: axis_pos[0]}) axis_pos.clear() elif len(axis_pos) == 2: center = center._replace( **{axis: (axis_pos[0] + axis_pos[1]) / 2.0}) axis_pos.clear() log.debug("Current axis positions for {}: {}".format(axis, axis_pos)) # Bounce back to release end stop bounce = value + (BOUNCE_DISTANCE_MM * (-distance / abs(distance))) robot.poses = instrument._move(robot.poses, **{axis: bounce}) robot.poses = instrument._move(robot.poses, z=safe_height) log.debug("Updated center point tip probe {}".format(center)) instrument._remove_tip(tip_length) return center