#print "G" + g_mode, "X{0:.8f}".format(x_f), "Y{0:.8f}".format(y_f), "Z{0:.8f}".format(interpolated_z) #lines.append("G" + str(g_mode) + " X{0:.8f}".format(x_f) + " Y{0:.8f}".format(y_f) + " Z{0:.8f}".format(interpolated_z)) lines.append("G" + str(g_mode) + " X{0:.8f}".format(x_f) + " Y{0:.8f}".format(y_f) + " Z{0:.8f}".format(interpolated_z) + " F{0:.8f}".format(g1_feed)) z_pos_prv = z_pos return lines _gc = read_gcode_file(gcode_file) #pnts = [] height_pnts = [] if not dry_run: grbl.setup("/dev/ttyUSB0") grbl.send_initial_command("") if height_map_file is not None: with open(height_map_file, "r") as fp: height_pnts.append([]) for line in fp: line = line.strip() if len(line)==0: continue if line[0] == '#': continue v = line.split() pnts.append( [ float(v[0]), float(v[1]), float(v[2]) ] ) height_pnts[0].append( [ float(v[0]), float(v[1]), float(v[2]) ] ) if not dry_run:
#print "G" + g_mode, "X{0:.8f}".format(x_f), "Y{0:.8f}".format(y_f), "Z{0:.8f}".format(interpolated_z) #lines.append("G" + str(g_mode) + " X{0:.8f}".format(x_f) + " Y{0:.8f}".format(y_f) + " Z{0:.8f}".format(interpolated_z)) lines.append("G" + str(g_mode) + " X{0:.8f}".format(x_f) + " Y{0:.8f}".format(y_f) + " Z{0:.8f}".format(interpolated_z) + " F{0:.8f}".format(g1_feed)) z_pos_prv = z_pos return lines _gc = read_gcode_file(gcode_file) pnts = [] if not dry_run: grbl.setup(tty_device) grbl.send_initial_command("") sys.stdout.write("\n#### ") cprint("READY TO CUT, REMOVE PROBE AND PRESS ENTER TO CONTINUE", "red", attrs=['blink']) sys.stdout.flush() sys.stdin.readline() if not dry_run: grbl.send_command("G1Z5F50") if grbl_spindle: grbl.send_command("S" + str(s_val)) grbl.send_command("M03") else:
#!/usr/bin/python # # use camera to home x axis # assumes the 'end stop' is an all black # region on the strip that the camera points to # # bails out if we've gone past the gMinPos import sys import numpy import cv2 import time import grbl grbl.setup() gCurAxis = 'y' gPosCur = 0 gPosMin = -10 gPosDel = [-1, -.1, -0.01] gPosDelLevel = 0 gShowWindowFlag = True #gShowWindowFlag = False gVerboseFlag = True gWidth = 640.0 gHeight = 480.0
if hasattr(args, 'z_up'): z_up = float(args.z_up[0]) if hasattr(args, 'z_down'): z_down = float(args.z_down[0]) if hasattr(args, 'tic'): tic = float(args.tic[0]) if hasattr(args, 'epsilon'): epsilon = float(args.epsilon[0]) if hasattr(args, 'file'): fn = args.file[0] if version_flag: print "# grbl height probe, version", version if verbose: print "# baud:", baud, "device:", device, "verbose:", verbose print "# x_start:", x_start, "x_end:", x_end, "y_start:", y_start, "y_end:", y_end, "z_up:", z_up, "z_down:", z_down print "# tic:", tic if not debug: grbl.setup(device, baud) grbl.var_epsilon = epsilon grid = [] line_no = 1 if fn: f = open(fn) for lines in f.readlines(): line_no += 1 l = lines.strip() if re.match('^\s*$', l) or re.match('^\s*#', l): if debug: print "# skipping line_no:", line_no, l
lines.append("G0 X{0:.8f}".format(x_f) + " Y{0:.8f}".format(y_f) + " Z{0:.8f}".format(z_ub)) #print "G" + g_mode, "X{0:.8f}".format(x_f), "Y{0:.8f}".format(y_f), "Z{0:.8f}".format(interpolated_z) #lines.append("G" + str(g_mode) + " X{0:.8f}".format(x_f) + " Y{0:.8f}".format(y_f) + " Z{0:.8f}".format(interpolated_z)) lines.append("G" + str(g_mode) + " X{0:.8f}".format(x_f) + " Y{0:.8f}".format(y_f) + " Z{0:.8f}".format(interpolated_z) + " F{0:.8f}".format(g1_feed)) z_pos_prv = z_pos return lines _gc = read_gcode_file(gcode_file) pnts = [] if not dry_run: grbl.setup() grbl.send_initial_command("") if height_map_file is not None: with open(height_map_file, "r") as fp: for line in fp: line = line.strip() if len(line)==0: continue if line[0] == '#': continue v = line.split() pnts.append( [ float(v[0]), float(v[1]), float(v[2]) ] ) else: #if dry_run: