def main(): args = sys.argv[1:] if len(args) == 0: return command, args = args[0], args[1:] command = command.lower() device = axi.Device() if command == 'zero': device.zero_position() elif command == 'home': device.home() elif command == 'up': device.pen_up() elif command == 'down': device.pen_down() elif command == 'on': device.enable_motors() elif command == 'off': device.disable_motors() elif command == 'move': dx, dy = map(float, args) device.move(dx, dy) elif command == 'goto': x, y = map(float, args) device.goto(x, y) else: pass
def signal_handler(signal, frame): print('You pressed Ctrl+C! Back home AxiDraw!') device = axi.Device() device.pen_up() device.goto(0, 0) device.disable_motors() sys.exit(0)
def main(): args = parser.parse_args() d = None #if args.axi is not None: if args.command == 'render': d = axi.Drawing.load(args.axi) d = d.rotate_and_scale_to_fit(12, 8.5, step=90) im = d.render() im.write_to_png(args.output) return device = axi.Device() if args.command == 'zero': device.zero_position() elif args.command == 'home': device.home() elif args.command == 'up': device.pen_up() elif args.command == 'down': device.pen_down() elif args.command == 'on': device.enable_motors() elif args.command == 'off': device.disable_motors() elif args.command == 'move': device.move(args.dx, args.dy) elif args.command == 'goto': device.goto(args.x, args.y) elif args.command == 'draw': d = axi.Drawing.load(args.axi) axi.draw(d) else: parser.error("command required")
def main(): d = axi.Device() d.pen_up() d.enable_motors() time.sleep(0.2) points = [] points.append((0, 0)) for i in range(10): while True: x = random.random() * 11 y = random.random() * 8.5 r = random.random() * 4 if x - r < 0 or x + r > 11: continue if y - r < 0 or y + r > 8.5: continue break rotation = random.random() * 2 * math.pi c = circle(x, y, r, 90, rotation) if random.random() < 0.5: c = list(reversed(c)) points.extend(c) points.append((0, 0)) d.run_path(points) d.wait() d.disable_motors()
def init(): global d global path d = axi.Device(max_velocity=7, jog_max_velocity=11) d.pen_up() d.enable_motors() time.sleep(0.2) path.append((0, 0)) d.disable_motors()
def __init__(self, global_vars=lambda: None): self.global_vars = global_vars try: global_vars.axi_device except AttributeError: global_vars.axi_device = axi.Device() self.device = global_vars.axi_device self.move_axi_modified = [] self.config_modified = []
def __init__(self): # AxiDraw try: self.p_axi_ = np.load('axi_parameters.npy').item() except Exception as e: self.p_axi_ = dict( steps_per_unit = axi.device.STEPS_PER_INCH, pen_up_position = axi.device.PEN_UP_POSITION, pen_up_speed = axi.device.PEN_UP_SPEED, pen_up_delay = axi.device.PEN_UP_DELAY, pen_down_position = axi.device.PEN_DOWN_POSITION, pen_down_speed = axi.device.PEN_DOWN_SPEED, pen_down_delay = axi.device.PEN_DOWN_DELAY, acceleration = axi.device.ACCELERATION, max_velocity = axi.device.MAX_VELOCITY, corner_factor = axi.device.CORNER_FACTOR, jog_acceleration = axi.device.JOG_ACCELERATION, jog_max_velocity = axi.device.JOG_MAX_VELOCITY ) print self.p_axi_ self.axi_ = axi.Device(**self.p_axi_) self.axi_.enable_motors() self.axi_.pen_up() self.axi_.home() # Camera self.params_ = np.load('camera_parameters.npz') self.align_ = np.load('m.npy') self.cam_ = cv2.VideoCapture(0) self.img_ = None # Drawing Data self.q_ = []#deque(maxlen=128) self.t_ex_ = None self.data_ = { 'drw' : False, # drawing 'pts' : [], 'up' : False, 'down': False } self.drw_ = np.full( shape=(334,437,3), fill_value=255, dtype=np.uint8)
def main(): font = axi.SCRIPTS ds = [ axi.Drawing(axi.text(line, font)).scale_to_fit_height(1) for line in LINES ] d = stack_drawings(ds, 0.1) # d = d.rotate_and_scale_to_fit(12, 8.5, step=90) # d = d.scale(0.02, 0.02) # d = d.center(12, 8.5) # d = d.move(0, 0, 0, 0) d = d.scale_to_fit(12, 8.5) # d = d.center(12, 8.5) d = d.move(6, 0, 0.5, 0) d = d.translate(0, 0.01) d = d.join_paths(0.01) d.render().write_to_png('out.png') print sum(x.t for x in axi.Device().plan_drawing(d))
def main(): dev = axi.Device(pen_down_position=25) # coord specification = (right(+x), down(+y)) #path = [ # (0,0), # (1,1), # (1,2), # (2,1), # (1,1) # ] dev.enable_motors() dev.pen_up() dev.home() dev.pen_down() dev.goto(1, 2) #dev.run_path(path) dev.pen_up() dev.home() dev.disable_motors()
def main(): args = sys.argv[1:] if len(args) == 0: return command, args = args[0], args[1:] command = command.lower() if command == 'render': d = axi.Drawing.load(args[0]) d = d.rotate_and_scale_to_fit(12, 8.5, step=90) path = args[1] if len(args) > 1 else 'out.png' im = d.render(scale=109 * 1, line_width=0.25 / 25.4) # show_axi_bounds=False, use_axi_bounds=False) im.write_to_png(path) return device = axi.Device() if command == 'zero': device.zero_position() elif command == 'home': device.home() elif command == 'up': device.pen_up() elif command == 'down': device.pen_down() elif command == 'on': device.enable_motors() elif command == 'off': device.disable_motors() elif command == 'move': dx, dy = map(float, args) device.move(dx, dy) elif command == 'goto': x, y = map(float, args) device.goto(x, y) elif command == 'draw': d = axi.Drawing.load(args[0]) axi.draw(d) else: pass
def main(fonts_pts_list): device = axi.Device() device.pen_x,device.pen_y = device.read_position() # reset device.command('R') # set pen up pos nice and high # pen up pos, default 16000, more higher device.command('SC', 5, 20000) # quickly put pen in known down pos # servo rate ("quick as possible") device.command('SC', 10, 0) device.pen_z = 20000 # pen down pos, default 12000, more higher device.command('SC', 4, device.pen_z) # pen down (200ms enough for "quick as possible") device.command('SP', 1, 200) pen_up(device) font_span = 1000 base_pt = [5000, 2000] scale_x = 3 scale_y = 3 for pts_list in fonts_pts_list: # find min max Z value min_z = None max_z = None for pts in pts_list: for pt in pts: if min_z is None or min_z > pt[2]: min_z = pt[2] if max_z is None or max_z < pt[2]: max_z = pt[2] # normalize pt for i,pts in enumerate(pts_list): for j,pt in enumerate(pts): pts_list[i][j][0] = pts_list[i][j][0] * scale_x pts_list[i][j][1] = pts_list[i][j][1] * scale_y pts_list[i][j][2] = ((draw_Z_Range[1] - draw_Z_Range[0]) / (max_z - min_z)) * (pts_list[i][j][2] - min_z) + draw_Z_Range[0] move_to(device, base_pt[0] + pts_list[0][0][1], base_pt[1] + pts_list[0][0][0], no_draw_Z, 2000) for i,pts in enumerate(pts_list): move_to(device, base_pt[0] + pts[0][1], base_pt[1] + pts[0][0], no_draw_Z, 500) for pt in pts: move_to(device, base_pt[0] + pt[1], base_pt[1] + pt[0], pt[2], 200) move_to(device, base_pt[0] + pts[-1][1], base_pt[1] + pts[-1][0], no_draw_Z, 300) # time.sleep(1) base_pt[1] += font_span # time.sleep(2) # move_to(device, 5000, 2000, 12000, 2000) # # move_to(device, 5000, 5000, 6000, 2000) # time.sleep(2) # move_to(device, 7000, 2000, 14000, 4000) # # move_to(device, 23385, 17000, 10000, 3000) # # move_to(device, 4000, 2000, 9000, 1200) pen_up(device) move_to(device, 0, 0, 20000, 2000)
help='''Number of vertical subdivisions for test plots''') args.add_argument('--padding', type=float, default=0.2, help='''Padding in inches for subdivided drawing''') args.add_argument('--size', type=float, default=8.5, help='''Reference work area size in inches''') args.add_argument('--y_up', type=bool, default=False, help='''If true this indicates that the input drawing has origin in the bottom left''') args.add_argument('--start_index', type=int, default=0, help='''Default start index''') cfg = args.parse_args() print(sys.argv) device = axi.Device() # V3_SIZEX and V3_SIZEY # - this value is NOT the size of your paper # - this value DOES control how PATHCMD scales x and y to your paper size # - x,y coordinate values passed to PATHCMD get mapped into to this range # - with 0.0 mapped to 0 (closest to the USB connector in both axes) # - and 1.0 mapped to V3_SIZEX or V3_SIZEY # - you can use coordinates >1.0 no problem # - they simply extrapolate beyond V3_SIZEX or V3_SIZEY # - so with an 8.5 x 11 inch paper you might choose V3_SIZEX==V3_SIZEY==8.5 # - with x coordinates > 1.0 to reach the extra 2.5 inches # - it's important that V3_SIZEX==V3_SIZEY if NX==NY==1 # - otherwise your PATHCMD drawing will be stretched or squished in one axis # - if you set NX and NY to values other than 1 # - V3_SIZEX and V3_SIZEY must have the opposite proportion to avoid squishing
import axi import time d = axi.Device() d.enable_motors() turtle = axi.Turtle() ##turtle.goto(0,0) # #turtle.pd() #turtle.pu() turtle.goto(5, 1) for i in range(360): print "move forward by 1" #turtle.pd() # pen down turtle.forward(0.01) # gehe 0.5inch nach vorwaerts turtle.rt(1) # drehe dich um 60grad #turtle.pu() # pen up drawing = turtle.drawing axi.draw(drawing) d.disable_motors()
def create_device(self): self.global_vars.axi_device = axi.Device() self.device = self.global_vars.axi_device
def connect_plotter(): d = axi.Device() d.enable_motors() d.zero_position() return d