Ejemplo n.º 1
0
def drop_pipette(swift: SwiftAPI, position: dict):
    # Hovering above trash
    dict_args = position
    dict_args['change_z_by'] = 70
    dict_args['wait'] = True
    swift.set_position(**dict_args)

    # back to normal location (relevant in case of using variables)
    dict_args['change_z_by'] = 0
    swift.set_position(**dict_args)
    current_position = swift.get_position()
    robot_move(swift=swift,
               position={
                   'x': current_position[0],
                   'y': current_position[1],
                   'z': position['z'],
                   'e': None,
                   'speed': None
               })
    dict_args = position
    dict_args['wait'] = True
    swift.set_position(**dict_args)
    swift.set_wrist(270)
    sleep(1)
    swift.set_wrist(90)

    # Hovering above trash
    dict_args = position
    dict_args['change_z_by'] = 70
    dict_args['wait'] = True
    swift.set_position(**dict_args)
    dict_args[
        'change_z_by'] = 0  # back to normal location(relevant in case of using variables)
Ejemplo n.º 2
0
protection_sip = 1.5
starting_x = 164.36
starting_y = -19
printing_z = 28.5

print('sleep 2 sec ...')
sleep(2)

print('device info: ')
print(swift.get_device_info())

print("Allowing extrusion")
swift.send_cmd_sync("M302 S0")

print('get_position:', swift.get_position())
swift.set_wrist(90)
swift.set_position(120, 0, 50, speed=15000, wait=True)  # Home
swift.set_position(131, -5, 90, speed=15000, wait=True)

#swift.set_position(139.88, -112.31, 60.24, speed=30000, timeout=30, wait=True) # Center in first pippet
#swift.set_position(z=-43.25, speed=30000, timeout=30, wait=True)  # Acquire pippet
#swift.set_position(z=-60, speed=300, timeout=30, wait=True)  # Acquire pippet
#swift.set_position(z=-65, speed=300, timeout=30, wait=True)  # Acquire pippet
#swift.set_position(z=-69, speed=300, timeout=30, wait=True)  # Acquire pippet
#sleep(0.1)
#swift.set_position(z=60.24, speed=30000, timeout=30, wait=True)

swift.set_position(x=221, y=-114.5, z=80, speed=30000, timeout=30,
                   wait=True)  # Center to water
swift.set_position(z=62, speed=30000, timeout=30, wait=True)  # Get close
swift.set_position(z=57, speed=700, timeout=30, wait=True)  # Smooth in
Ejemplo n.º 3
0
    swift.set_position(**dict_args)
    dict_args = ({'x': 140.32, 'y': (-109), 'z': (-67), 'e': 0})
    dict_args['wait'] = True
    swift.set_position(**dict_args)
    dict_args = ({'x': 140.32, 'y': (-109), 'z': (-67.5), 'e': 0})
    dict_args['wait'] = True
    swift.set_position(**dict_args)
    dict_args = ({'x': 140.32, 'y': (-109), 'z': 10, 'e': 0})
    dict_args['wait'] = True
    swift.set_position(**dict_args)
    dict_args = ({'x': 160.32, 'y': 40, 'z': 10, 'e': 0})
    dict_args['wait'] = True
    swift.set_position(**dict_args)
    dict_args = ({'x': 140.32, 'y': (-109), 'z': 0, 'e': 0})
    dict_args['wait'] = True
    swift.set_position(**dict_args)
    dict_args = ({'x': 140.32, 'y': (-109), 'z': (-60), 'e': 0})
    dict_args['wait'] = True
    swift.set_position(**dict_args)
    swift.set_wrist(90)
    sleep(1)
    swift.set_wrist(0)
    sleep(1)
    swift.set_wrist(90)
    sleep(1)
    dict_args = ({'x': 140.32, 'y': (-109), 'z': 0, 'e': 0})
    dict_args['wait'] = True
    swift.set_position(**dict_args)
    swift.set_position(e=0, speed=1500, timeout=30, wait=True)
    swift.set_position(120, 0, 50, speed=1500, timeout=30, wait=True)
Ejemplo n.º 4
0
offset_x = 0
offset_y = 193
total = len(coords)
i = 0
for i in range(50):
    print("e={}".format(i / 2))
    swift.set_position(10,
                       193,
                       50,
                       extrude=i / 2,
                       wait=True,
                       speed=500,
                       timeout=30)
    sleep(1)
    swift.set_wrist()

# for coord in coords:
#     xcord = str(int(coord['x']) + offset_x)
#     ycord = str(int(coord['y']) + offset_y)
#     print(xcord, ycord)
#     swift.set_position(x=xcord, y=ycord, speed=1500, wait=True)
#     print('get_position:', swift.get_position())
#     swift.set_position(z=40, wait=True, speed=500)
#     print('get_position:', swift.get_position())
#     swift.set_position(z=45, wait=True, speed=500)
#     print("{i}/{total}".format(i=i, total=total))
#     i+=1
#
#
Ejemplo n.º 5
0
def print_pattern(swift: SwiftAPI, pattern_format: str, pipette_position: dict,
                  starting_position: dict, liquid_position: dict,
                  disposal_position: dict):
    # Reading the coords file into a list
    print(f'retrieveing coords from {pattern_format}')
    coords = []
    with open(os.path.join('uploads\coords', pattern_format), 'r') as f:
        for line in f:
            x, y = line.strip().split("\,")
            coords.append((float(x), float(y)))

    # Initializing required variables
    current_liquid = 0
    release_step = -0.070
    total_liquid = release_step * (len(coords) + 100) * 1.75
    step_proportional = 2
    protection_sip = -1.5

    # Resetting arm position to home
    swift.set_wrist(90)
    swift.set_position(120, 0, 50, speed=15000, wait=True)

    # Initializing required positions
    pip_args = pipette_position
    pip_args['wait'] = True
    start_args = starting_position
    start_args['wait'] = True
    starting_x = start_args['x']
    starting_y = start_args['y']
    printing_z = start_args['z']
    liquid_args = liquid_position
    liquid_args['wait'] = True
    disposal_args = disposal_position
    disposal_args['wait'] = True

    # Moving to pipette pick up location, while preserving arm's height
    temp_z = pip_args['z']
    pip_args['z'] = 60
    swift.set_position(**pip_args)
    pip_args['z'] = temp_z
    swift.set_position(**pip_args)
    sleep(1)
    swift.set_position(z=105, speed=1500, timeout=30, wait=True)

    # Moving to liquid location, while preserving arm's height
    temp_z = liquid_args['z']
    liquid_args['z'] = 105
    swift.set_position(**liquid_args)
    liquid_args['z'] = temp_z
    swift.set_position(**liquid_args)

    # Extrude the liquid according to the amount of coords
    swift.set_position(e=total_liquid, speed=1500, timeout=30, wait=True)
    current_liquid = total_liquid
    swift.set_position(z=90, speed=30000, timeout=30, wait=True)

    # Moves to printing starting point
    swift.set_position(x=(step_proportional * coords[0][0]) + starting_x,
                       y=(step_proportional * coords[0][1]) + starting_y,
                       z=60,
                       speed=30000,
                       timeout=30,
                       wait=True)

    # Printing image's coords
    picture = coords
    total_len = len(picture)
    current_step = 0
    for x, y in picture:
        current_step += 1
        print("{c_step}/{total}".format(c_step=current_step, total=total_len))
        current_liquid -= release_step
        print(x, y)
        swift.set_position(x=starting_x + (step_proportional * x),
                           y=starting_y + (step_proportional * y),
                           wait=True,
                           speed=1500)
        sleep(0.3)
        swift.set_position(z=printing_z, wait=True)
        swift.set_position(e=current_liquid, wait=True, speed=500)
        swift.set_position(z=printing_z + 5, wait=True)

    # Printing last step
    current_liquid += release_step
    swift.set_position(z=printing_z, wait=True)
    swift.set_position(e=current_liquid, wait=True, speed=300)
    swift.set_position(z=printing_z + 3, wait=True)

    # Releasing the rest of the liquid
    # Dropping off the pipette at disposal area
    swift.set_position(e=current_liquid, z=155, speed=30000, wait=True)
    temp_z = disposal_args['z']
    disposal_args['z'] = 155
    swift.set_position(x=269,
                       y=-90,
                       z=155,
                       e=current_liquid,
                       speed=30000,
                       wait=True)
    swift.set_position(z=155, speed=30000, timeout=20, wait=True)
    swift.set_position(e=0, speed=30000, timeout=20, wait=True)
    swift.set_wrist(0)
    swift.set_wrist(90)
    swift.set_position(z=150, speed=30000, wait=True)
Ejemplo n.º 6
0
def robot_wrist(swift: SwiftAPI, angle: float):
    swift.set_wrist(angle=angle)
    sleep(1)
Ejemplo n.º 7
0
print('device info: ')
print(swift.get_device_info())
sleep(2)
# swift.reset()
swift.set_position(x=300, wait=True)
sleep(3)
print(swift.get_position())
sleep(3)
swift.set_position(y=0, wait=True)
sleep(3)

# swift.set_position(x=200,y=0, z=45, wait=True)
swift.set_position(z=85, wait=True)
sleep(2)
for x in range(0, 180, 30):
    swift.set_wrist(angle=x, wait=True)
    sleep(0.2)
swift.set_wrist(angle=90, wait=True)
swift.set_buzzer()
sleep(2)
swift.set_position(x=300, y=0, z=110, wait=True)

#
swift.set_position(x=330, y=0, z=85, wait=True)
sleep(2)
for x in range(0, 180, 30):
    swift.set_wrist(angle=x, wait=True)
    sleep(0.2)
swift.set_wrist(angle=90, wait=True)
swift.set_buzzer()
sleep(2)
Ejemplo n.º 8
0
print('\nset X350 Y0 Z50 F500 ...')
swift.set_position(230, 0, 70, speed=1500, wait=True)

# 下降到桌面
swift.set_position(230, 0, z=1, speed=1500, wait=True)

# 气泵
swift.set_pump(on=True)
#升起
# swift.set_position(230, 0, 70, speed=1500,wait=True)
swift.set_position(230, 0, 2, speed=1500, wait=True)  #原地旋转
#旋转90度
print('角度:', swift.get_servo_angle())  #[90.09, 74.76, 39.27, 93.0]
print('旋转90度')
ret = swift.set_wrist(angle=90 - 90, wait=True)  #默认是90度
print('角度:', swift.get_servo_angle(), ret)  #[90.09, 74.94, 39.01, 104.0]
sleep(1)
ret = swift.set_wrist(angle=90 - 60, wait=True)  #
print('角度:', swift.get_servo_angle(), ret)  #[90.09, 75.03, 38.92, 15.0]
sleep(1)
ret = swift.set_wrist(angle=90 - 30, wait=True)  #
print('角度:', swift.get_servo_angle(), ret)  #[90.09, 75.03, 38.92, 52.0]
sleep(1)
ret = swift.set_wrist(angle=90 + 0, wait=True)  #
print('角度:', swift.get_servo_angle(), ret)  #[90.09, 75.03, 38.92, 65.0]
sleep(1)
ret = swift.set_wrist(angle=90 + 30, wait=True)  #
print('角度:', swift.get_servo_angle(), ret)  #[90.09, 75.03, 38.92, 94.0]
sleep(1)
ret = swift.set_wrist(angle=90 + 60, wait=True)  #
Ejemplo n.º 9
0
# -*- coding: utf-8 -*-

# https://github.com/zeth/inputs

import inputs
import os
import sys
from time import sleep
from uf.wrapper.swift_api import SwiftAPI
from uf.utils.log import *

w = 90
swift = SwiftAPI()  # {'hwid': 'USB VID:PID=2341:0042'}
sleep(2)
swift.set_position(150, 0, 150, speed=20000, timeout=20)
swift.set_wrist(90, wait=True)  # lang
swift.flush_cmd()
sleep(1)

# print(inputs.devices.gamepads)

while True:

    events = inputs.get_gamepad()
    for event in events:

        if event.code == 'ABS_X' and event.state < -20000:
            swift.set_position(y=-1, speed=20000, relative=True, wait=True)
            print('links')
        if event.code == 'ABS_X' and event.state > 10000:
            swift.set_position(y=+1, speed=20000, relative=True, wait=True)