if __name__ == '__main__': print parse('0.2,0.3in', getUnits=True) print parse('0.2,0.3in', getUnits=True) print parse('.2,0.3in', getUnits=True) print parse('2,.03mm', getUnits=True) print parse('2,3mm', getUnits=True) print parse('2222,322mm', getUnits=True) print parse('2222.023,322.2', getUnits=True) ## I should wrap this in a __main__ section if __name__ == '__main__' and False: # Initialize the args start = datetime.now() args = argv.arg( description='Python GCode modifications', getFile=True, # get gcode to process getMultiFiles=True, # accept any number of files otherOptions=OPTIONS, # Install some nice things getDevice=False) # We dont need a device # optimize each file in the list for gfile in args.gcode: # only process things not processed before. # c = re.match(r'(?P<drill>\.drill\.tap)|(?P<etch>\.etch\.tap)', gfile.name) c = re.match(r'(.+)(\.tap)', gfile.name) if c: # either a drill.tap or etch.tap file mod(gfile) print '%s finished in %s' % (args.name, deltaTime(start))
newLength = origLength if key == '+': newLength *= 2 else: newLength /= 2 # round to the nearest mil because we're outputting that resolution with relative addressing # if we try to use fractional mils, we'll end up with the position we tell the user not matching where the machine actually is newLength = round(newLength*1000)/1000 puts(colored.blue(' > moveLength is now: %.3f inch\n'%newLength)) return newLength # Get the arguments passed into the program args = argv.arg(description='Simple python alignment tool', defaultTimeout=0.25) # Using with logic to handle tear down and the sort. with Communicate(args.device, args.speed, timeout=args.timeout, debug=args.debug, quiet=args.quiet) as serial: # lets begin by giving the user some nice information puts(colored.blue(HELP)) for line in startCommand.splitlines(): serial.run(line) # Not only do we need to talk to the serial device, we also need # some input from the user, so create a terminal object to do this. print '<waiting for key>' with Terminal() as terminal: while True:
ext4=dict(args=['--offsetz'], default=0.0, type=float, help='Set z offset length in inches'), ext5=dict(args=['--rotate'], default=0.0, type=float, help='Rotate about the origin by some angle. Rotates after offset'), ) if __name__ == '__main__': # Initialize the args start = datetime.now() args = argv.arg(description='Python GCode optimizations', otherOptions=EXTRAARGS, # Install some nice things getFile=True, # get gcode to process getMultiFiles=True, # accept any number of files getDevice=False) if args.zmove != 0: Z_MOVE = args.zmove if args.zdrill != 0: Z_DRILL = args.zdrill if args.zmill != 0: Z_MILL = args.zmill # print vars(args) # import sys # sys.exit() # optimize each file in the list for gfile in args.gcode:
import re, sys, time from datetime import datetime,timedelta from clint.textui import puts, colored, progress from lib import argv from lib.communicate import Communicate from lib.util import deltaTime # from pysurvey import util # util.setup_stop() RX_BUFFER_SIZE = 128 # Initialize the args args = argv.arg(description='Simple python GRBL streamer', getFile=True) # Let go! start = datetime.now() puts(colored.blue(' Starting file: %s \n at %s'%(args.gcode.name, start))) # read the full file and then close so that it cannot change. # I am pretty sure even at 1M lines, I should be able to hold this in mem lines = args.gcode.readlines() args.gcode.close() # get a serial device and wake up the grbl, by sending it some enters with Communicate(args.device, args.speed, timeout=args.timeout, debug=args.debug, quiet=args.quiet) as serial: inBuf = [] # array of length of lines in buffer
print box[0:2] image = Drawing(outfile) #, bbox=box) image.process(tool) image.save() # how long did this take? puts(colored.green('Time to completion: %s' % (deltaTime(start)))) print if __name__ == '__main__': ## I should wrap this in a __main__ section # Initialize the args start = datetime.now() args = argv.arg( description='PyGRBL gcode imaging tool', getFile=True, # get gcode to process getMultiFiles=True, # accept any number of files getDevice=False) # We dont need a device # optimize each file in the list for gfile in args.gcode: # only process things not processed before. # c = re.match(r'(?P<drill>\.drill\.tap)|(?P<etch>\.etch\.tap)', gfile.name) c = re.match(r'(.+)(\.tap)', gfile.name) # c = True # HAX and accept everything if c: # either a drill.tap or etch.tap file main(gfile, args=args) print '%s finished in %s' % (args.name, deltaTime(start))
image = Image(outfile, gridsize=box[0:2]) image.process(tool) image.save() # how long did this take? puts(colored.green('Time to completion: %s' % (deltaTime(start)))) print if __name__ == '__main__': ## I should wrap this in a __main__ section # Initialize the args start = datetime.now() args = argv.arg( description='PyGRBL gcode imaging tool', getFile=True, # get gcode to process getMultiFiles=True, # accept any number of files otherOptions=EXTRAARGS, # Install some nice things getDevice=False) # We dont need a device # optimize each file in the list for gfile in args.gcode: # only process things not processed before. # c = re.match(r'(?P<drill>\.drill\.tap)|(?P<etch>\.etch\.tap)', gfile.name) c = re.match(r'(.+)(\.tap)', gfile.name) # c = True # HAX and accept everything if c: # either a drill.tap or etch.tap file main(gfile, args=args) print '%s finished in %s' % (args.name, deltaTime(start))
print box[0:2] image = Drawing(outfile)#, bbox=box) image.process(tool) image.save() # how long did this take? puts(colored.green('Time to completion: %s'%(deltaTime(start)))) print if __name__ == '__main__': ## I should wrap this in a __main__ section # Initialize the args start = datetime.now() args = argv.arg(description='PyGRBL gcode imaging tool', getFile=True, # get gcode to process getMultiFiles=True, # accept any number of files getDevice=False) # We dont need a device # optimize each file in the list for gfile in args.gcode: # only process things not processed before. # c = re.match(r'(?P<drill>\.drill\.tap)|(?P<etch>\.etch\.tap)', gfile.name) c = re.match(r'(.+)(\.tap)', gfile.name) # c = True # HAX and accept everything if c: # either a drill.tap or etch.tap file main(gfile, args=args) print '%s finished in %s'%(args.name,deltaTime(start))
image = Image(outfile, gridsize=box[0:2]) image.process(tool) image.save() # how long did this take? puts(colored.green('Time to completion: %s'%(deltaTime(start)))) print if __name__ == '__main__': ## I should wrap this in a __main__ section # Initialize the args start = datetime.now() args = argv.arg(description='PyGRBL gcode imaging tool', getFile=True, # get gcode to process getMultiFiles=True, # accept any number of files otherOptions=EXTRAARGS, # Install some nice things getDevice=False) # We dont need a device # optimize each file in the list for gfile in args.gcode: # only process things not processed before. # c = re.match(r'(?P<drill>\.drill\.tap)|(?P<etch>\.etch\.tap)', gfile.name) c = re.match(r'(.+)(\.tap)', gfile.name) # c = True # HAX and accept everything if c: # either a drill.tap or etch.tap file main(gfile, args=args) print '%s finished in %s'%(args.name,deltaTime(start))
f.write(output) ''' with open(outfile,'w') as f: f.write(output) ''' # how long did this take? puts(colored.green('Time to completion: %s'%(deltaTime(start)))) print if __name__ == '__main__': start = datetime.now() args = argv.arg(description='PyGRBL gcode imaging tool', getFile=True, # get gcode to process getMultiFiles=True, # accept any number of files; WHY MUST THIS BE TRUE for it to work? otherOptions=EXTRAARGS, # "Install some nice things" very descriptive!!! getDevice=False) # We dont need a device ''' if type(args.z_surf) == str: print "using the z surface file" print args.z_surf surface_file_name = args.z_surf else: print "looking for a z correction surface file in the default name: probe_test.out" surface_file_name = 'probe_test.out' ''' surface_file_name = args.z_surf #print "using the z surface file"
class Home(object): def __init__(self): # self.serial = pass if __name__ == '__main__': options = dict(command=dict(args=['reset'], nargs='?', default=False, help='reset the machine so that it does not home')) args = argv.arg(description=__DOC__, # getDevice=False, otherOptions=options) with Communicate(args.device, args.speed, timeout=args.timeout, debug=args.debug, quiet=args.quiet) as serial: if args.reset: for line in RESET.splitlines(): serial.run(line) else: for line in SETUP.splitlines(): serial.run(line) #
print parse('0.2,0.3in', getUnits=True) print parse('0.2,0.3in', getUnits=True) print parse('.2,0.3in', getUnits=True) print parse('2,.03mm', getUnits=True) print parse('2,3mm', getUnits=True) print parse('2222,322mm', getUnits=True) print parse('2222.023,322.2', getUnits=True) ## I should wrap this in a __main__ section if __name__ == '__main__' and False: # Initialize the args start = datetime.now() args = argv.arg(description='Python GCode modifications', getFile=True, # get gcode to process getMultiFiles=True, # accept any number of files otherOptions=OPTIONS, # Install some nice things getDevice=False) # We dont need a device # optimize each file in the list for gfile in args.gcode: # only process things not processed before. # c = re.match(r'(?P<drill>\.drill\.tap)|(?P<etch>\.etch\.tap)', gfile.name) c = re.match(r'(.+)(\.tap)', gfile.name) if c: # either a drill.tap or etch.tap file mod(gfile) print '%s finished in %s'%(args.name,deltaTime(start))
def tweakLength(origLength, key): newLength = origLength if key == '+': newLength *= 2 else: newLength /= 2 # round to the nearest mil because we're outputting that resolution with relative addressing # if we try to use fractional mils, we'll end up with the position we tell the user not matching where the machine actually is newLength = round(newLength * 1000) / 1000 puts(colored.blue(' > moveLength is now: %.3f inch\n' % newLength)) return newLength # Get the arguments passed into the program args = argv.arg(description='Simple python alignment tool', defaultTimeout=0.25) # Using with logic to handle tear down and the sort. with Communicate(args.device, args.speed, timeout=args.timeout, debug=args.debug, quiet=args.quiet) as serial: # lets begin by giving the user some nice information puts(colored.blue(HELP)) for line in startCommand.splitlines(): serial.run(line) # Not only do we need to talk to the serial device, we also need # some input from the user, so create a terminal object to do this. print '<waiting for key>'
#!/usr/bin/env python # command.py : A simple command prompt # [2012.08.02] - Mendez: cleaned up using my libraries # [2012.01.10] - SJK: original version import re, readline, time from lib import argv from lib.communicate import Communicate from clint.textui import colored, puts # Initialize the args args = argv.arg( description='Simple python grbl command prompt for debuging the GRBL') # get a serial device and wake up the grbl, by sending it some enters with Communicate(args.device, args.speed, timeout=args.timeout, debug=args.debug, quiet=args.quiet) as serial: # now we send commands to the grbl, and wait waitTime for some response. while True: # Get some command try: x = raw_input('GRBL> ').strip() if x.lower() in ['q', 'exit', 'quit']: break if x.lower() in ['r', 'reset']: serial.sendreset() if x in ['~']: serial.run('~\n?') # run it if is not a quit switch serial.run(x)
#!/usr/bin/env python # command.py : A simple command prompt # [2012.08.02] - Mendez: cleaned up using my libraries # [2012.01.10] - SJK: original version import re, readline, time from lib import argv from lib.communicate import Communicate from clint.textui import colored,puts # Initialize the args args = argv.arg(description='Simple python grbl command prompt for debuging the GRBL') # get a serial device and wake up the grbl, by sending it some enters with Communicate(args.device, args.speed, timeout=args.timeout, debug=args.debug, quiet=args.quiet) as serial: # now we send commands to the grbl, and wait waitTime for some response. while True: # Get some command try: x = raw_input('GRBL> ').strip() if x.lower() in ['q','exit','quit']: break if x.lower() in ['r','reset']: serial.sendreset() if x in ['~']: serial.run('~\n?') # run it if is not a quit switch serial.run(x) except KeyboardInterrupt: puts(colored.red('Emergency Feed Hold. Enter "~" to continue'))
class Home(object): def __init__(self): # self.serial = pass if __name__ == '__main__': options = dict( command=dict(args=['reset'], nargs='?', default=False, help='reset the machine so that it does not home')) args = argv.arg( description=__DOC__, # getDevice=False, otherOptions=options) with Communicate(args.device, args.speed, timeout=args.timeout, debug=args.debug, quiet=args.quiet) as serial: if args.reset: for line in RESET.splitlines(): serial.run(line) else: for line in SETUP.splitlines(): serial.run(line) #
#!/usr/bin/env python #probing uneven surfaces with robots #by Mike Erickstad using libraries developed by A J Mendez PhD from numpy import arange from lib import argv from lib.grbl_status import GRBL_status from lib.communicate import Communicate from clint.textui import puts, colored import time, readline import numpy as np args = argv.arg(description='Simple python grbl surface probe pattern') DEBUG_VERBOSE = False X_MAX = 2.5 Y_MAX = 2.0 X_STEP = 0.5 Y_STEP = 0.5 HIGH_Z = 0.020 LOW_Z = -0.030 PROBE_FEED_RATE = 0.2 DESCENT_SPEED = 2.0/60.0 DESCENT_TIME = HIGH_Z/DESCENT_SPEED Surface_Data = np.empty([len(arange(0, X_MAX+X_STEP/2.0, X_STEP)),len(arange(0, Y_MAX+Y_STEP/2.0, Y_STEP))]) Z=HIGH_Z converged = False