Esempio n. 1
0
    def __init__(self,
                 uarm_tty_port='/dev/ttyUSB1',
                 uart_delay=2,
                 initial_position=initial_position,
                 servo_attach_delay=5,
                 set_position_delay=5,
                 servo_detach_delay=5,
                 pump_delay=5,
                 scan_x_displacement=5,
                 scan_y_displacement=5,
                 scan_z_displacement=0,
                 stride_x=2,
                 stride_y=2,
                 stride_z=0):

        self.uarm_tty_port = uarm_tty_port
        self.uart_delay = uart_delay
        self.initial_position = initial_position
        self.servo_attach_delay = servo_attach_delay
        self.set_position_delay = set_position_delay
        self.servo_detach_delay = servo_detach_delay
        self.pump_delay = pump_delay
        self.scan_x_displacement = scan_x_displacement
        self.scan_y_displacement = scan_y_displacement
        self.scan_z_displacement = scan_z_displacement
        self.stride_x = stride_x
        self.stride_y = stride_y
        self.stride_z = stride_z

        self.uarm = pyuarm.UArm(port_name=self.uarm_tty_port)
        self.handle_exit_signals()

        time.sleep(self.uart_delay)
Esempio n. 2
0
 def __init__(self, mute=False, projector=True):
     #uArm
     self.arm = pyuarm.UArm(debug=False,mac_address='FC:45:C3:24:76:EA', ble=False)
     
     self.arm.connect()
     
     self.speed = 200 # speed limit
     self.ground = 30 # z value to touch suction cup to ground 
     self.position = np.array([[0],[150],[150]]) # default start position
     self.arm.set_position(0, 150, 150, speed=self.speed, wait=True) #just to be safe
     self.mute = mute # controls if sounds are made of not
     #Projector
     self.projector = projector # controls if projections are made or not
     # commenting out projection
     ####cv2.startWindowThread()
     ####cv2.namedWindow("window", cv2.WND_PROP_FULLSCREEN)
     ####cv2.setWindowProperty("window",cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)
     self.projection_process = None
     # commenting out projection
     ####self.project() # start with blank projection
     # camera
     self.setup_camera()
     self.setup_calibrators()
     self.view = None #most recent camera image captured
     self.tempimgpath = '/tmp/hirocurrentframe.jpg'
Esempio n. 3
0
def moving():
    #获取读入的点集合
    poionts = read_data()
    for each_point in poionts:
        print  each_point
    #机械臂初始化
    uarm = pyuarm.UArm()
    time.sleep(1)
    #写每个点
    for each_point in poionts:
        print each_point
        #蘸墨水
        if (each_point[0] >60):
            uarm.set_position(each_point[0], each_point[1], each_point[2], 40)
            time.sleep(1.2)
        #写字
        else:
            uarm.set_position(each_point[0], each_point[1], each_point[2], 100)
            time.sleep(1)
    #释放机械臂并断开连接;如果上面移动出错,无法执行uarm.set_servo_detach()语句
    uarm.set_servo_detach()
    uarm.disconnect()
    return
Esempio n. 4
0
import picamera
from time import sleep
import cv2
import pyuarm

arm = pyuarm.UArm()
arm.connect()
arm.set_position(0, 200, 240)

#width=4032
#height=3040
width = 1920
height = 1200
camera = cv2.VideoCapture(0)
camera.set(cv2.CAP_PROP_FRAME_WIDTH, width)
camera.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
#camera.set(cv2.CAP_PROP_EXPOSURE, 1000)
camera.set(cv2.CAP_PROP_BUFFERSIZE, 1)  # don't capture multiple frames

i = 0
while True:
    success, frame = camera.read()
    if not success:
        continue
    cv2.imshow('Preview', cv2.resize(frame, (1920, 1080)))
    key = cv2.waitKey(1)
    if key % 256 == 27:
        break  # escape
    elif key == ord('c'):
        # c - key means capture
        print(f"capturing to chessboard_img_fhd/image{i}_0.jpg")