Exemplo n.º 1
0
def main():
    yolo = detect.Yolo()
    cm = camera.Camera(num=1)
    homex, homey, homez = 200, 0, 70
    dbt = dobot.Dobot(homex, homey, homez)

    while True:
        try:
            img = cm.getImage()
            detectedImg, boxes, nums = yolo.detect(img)
            gain = 50

            if (nums[0] > 0):
                y = (boxes[0][0][0] + boxes[0][0][2] - 1) * gain
                x = (boxes[0][0][1] + boxes[0][0][3] - 1) * gain
                print("x,y:", x, y)
                pose = dbt.getPose()
                dbt.move(int(pose.x - x), int(pose.y - y), homez, 0)
                print("dobot x,y:pose.x,pose.y", pose.x, pose.y)

            cv2.imshow('frame', detectedImg)
            cv2.waitKey(1)
        except KeyboardInterrupt:
            dbt.dobotDisconnect()
            break
Exemplo n.º 2
0
 def __init__(self, emulation=False):
     self.emulation = emulation
     if (self.emulation is False):
         port = list_ports.comports()[0].device
         print(port)
         self.device = dobot.Dobot(port=port, verbose=False)
         self.device.speed()
     else:
         self.device = None
         self.pastStep = 1
         self.xList = [259.1198]
         self.yList = [0]
         self.zList = [-8.5687]
     self.position = None  #(x, y, z, r, j1, j2, j3, j4)
     self.getTime = None
##################################################################################
############# mini assembly first conveyor cam is yellow jig #####################
##################################################################################

import cv2
import numpy as np
import imutils
import dobot
import serial
from serial.tools import list_ports

port=list_ports.comports()[0].device
d1 = dobot.Dobot(port=port, verbose=True)

d1.motor(50)

d1.movel(205, 0, 160, 0)
d1.delay(3)
placex=180
placey=-203
yv=0
o=0

#####funtion representing a fixed set of instructions to robot#####
def dobot(X,Y,xp,yp):
	#d1.movel(250, 0, 50, 0)
	#d1.delay(2)
	d1.movel(X, Y, 40, 0)
	d1.delay(0.5)
	d1.movel(X, Y, -6, 0)
	d1.delay(2)
Exemplo n.º 4
0
def main():
    available_ports = glob('/dev/cu.SLAB*')  # mask for OSX Dobot port
    if len(available_ports) == 0:
        print('no port found for Dobot Magician')
        exit(1)

    device = dobot.Dobot(port=available_ports[0])

    time.sleep(0.5)
    # device.speed(100)
    # print(device.go(250.0, 0.0, 80.0))
    # print('hajs')
    # device.speed(100)
    # print(device.go(250.0, 0.0, 0.0))

    print("start")

    # device.set_home(250, 100, 50, 0)
    # print(device.go_home())
    while False:
        for i in range(80, 150, 10):
            print(device.set_conveyor(1, 1, i))
            time.sleep(2)
        break
        # print(device.go(260.8829040527344, -103.0121078491211, 12.091949462890625))
        # print(device.set_cupper(1, 1))
        # time.sleep(0.5)
        # print(device.go(260.11785888671875, 42.92505645751953, 90.23689270019531))

        # print(device.go(258.7375183105469, 168.59320068359375, 12.011768341064453))
        # time.sleep(0.5)
        # print(device.set_cupper(1, 0))
        # print(device.go(261.3182678222656, 16.561960220336914, 90.10472106933594))
        # time.sleep(0.5)

    while True:
        try:
            cmd = (input('enter command: ')).split()
            param = list(map(int, cmd[1:]))
            cmd = cmd[0]
            if cmd:
                if cmd == 'conveyor':
                    print(param[0])
                    print(device.set_conveyor(1, 0, param[0]))
                elif cmd == 'cupper':
                    print(device.set_cupper(1, param[0]))
                elif cmd == 'go_home':
                    print(device.go_home())
                elif cmd == 'set_home':
                    print(
                        device.set_home(param[0], param[1], param[2],
                                        param[3]))
                elif cmd == 'get_home':
                    print(device.get_home())
                elif cmd == 'go':
                    print(device.go(param[0], param[1], param[2], param[3]))
                elif cmd == 'get_pose':
                    print(device.get_pose())
                elif cmd == 'setvelacc':
                    print(device.speed(param[0], param[1]))
                elif cmd == 'clear':
                    print(device.clear_alarm())
        except Exception as e:
            print(e)
        pass

    print('end')
    # print(device._get_pose())
    # print('adfgd')
    # time.sleep(2)
    device.close()