Beispiel #1
0
def dobotPort(port, fungsi):
    if fungsi == 1:
        main = Dobot(port=port)
        return main
    if fungsi == 2:
        jog = JOG(port=port)
        return jog
Beispiel #2
0
def dobot():
    port = list_ports.comports()[0].device
    device = Dobot(port=port, verbose=True)

    (x, y, z, r, j1, j2, j3, j4) = device.pose()
    y += 50
    device.move_to(x, y, z, r, wait=False)
    x -= 15
    device.move_to(x, y, z, r, wait=False)
    x += 30
    y += 20
    device.move_to(x, y, z, r, wait=False)
    x += 30
    y -= 20
    device.move_to(x, y, z, r, wait=False)
    x -= 15
    device.move_to(x, y, z, r, wait=False)
    y -= 50
    device.move_to(x, y, z, r, wait=False)
    x -= 30
    device.move_to(x, y, z, r, wait=False)

    device.move_to(
        x, y, z, r,
        wait=True)  # we wait until this movement is done before continuing

    device.close()
Beispiel #3
0
    def __init__(self, dobotPort='/dev/ttyUSB0'):
        available_ports = glob('/dev/tty*USB*')  # mask for OSX Dobot port
        if len(available_ports) == 0:
            print('no port /dev/tty*USB* found for Dobot Magician')
            exit(1)

        #self.DobotPort = 'COM4'
        self.DobotPort = dobotPort;

        self.ecRelay = Relay(18);#bcm pin for physical pin 12
        self.pdRelay = Relay(24);#bcm for physical 18
        self.rhRelay = Relay(23);#bcm for physical 16
        self.gripper = ServoGripper(2);
        self.dvc = DigitalVoltControl();

        self.lastCmd = [0,0,0,0]; #x, y, z, r

        print("Setting Port to " + self.DobotPort);
        self.device = Dobot(port=self.DobotPort)
        time.sleep(1)
        if self.device is not None:
            print("Opened connection")

        self.device.speed(60)

        self.z_up = 100
        self.z_down = -70
        #self.RH_Voltage = 2.5;
        #self.PD_Voltage = 1.9;
        #self.EC_Voltage = 4.8;
        
        self.home_xyzr = [215, 0, self.z_up, 0];                    
        global global_status
        global_status = "Rh Electroplating";
def move(from_x, from_y, from_z, to_x, to_y, to_z):
    convert_arm_coordinate(from_x, from_y, from_z)
    bot = Dobot(port=port, verbose=True)
    bot.move_to(finx, finy, finz)
    bot._set_end_effector_suction_cup(True)
    bot.move_to(finx, finy, 60)
    convert_arm_coordinate(to_x, to_y, to_z)
    bot.move_to(finx, finy, 60)
    bot.move_to(finx, finy, finz)
    bot.suck(False)
def connect_dobot():

    available_ports = glob('/dev/ttyUSB0')  # mask for OSX Dobot port

    if len(available_ports) == 0:
        print("NOT FOUND!!!")
        print('no port found for Dobot Magician')
        exit(1)
    #
    device = Dobot(port=available_ports[0])
    print("Connected")

    return device
Beispiel #6
0
    def __init__(self,streamload,mtx=[],dist=[]):
        self.refh = 20
        self.z_ = None
        self.H = []
        self.imaskG = []
        self.mtx = mtx
        self.dist = dist
        self.awaycoor = (-25,-230,50)
        self.cencoor = (254,8,13)
        self.armcp = np.array([[271.55,7.53],[272.76,91.28],[319.10,6.78],
                           [268.29,-163.73],[207.71,77.28],[304.95,-91.05]])
        self.streamload = streamload

        port = list_ports.comports()[0].device
        device = Dobot(port=port,verbose=False)
        self.device = device
        self.columns = os.get_terminal_size().columns
    def _connect_dobot(self, i):
        try:
            portArray = [
                "/dev/ttyUSB0", "/dev/ttyUSB01", "/dev/ttyUSB2",
                "/dev/ttyUSB3", "/dev/ttyUSB4", "/dev/ttyUSB5", "/dev/ttyS0",
                "/dev/ttyS1", "/dev/ttyS2", "/dev/ttyS3", "/dev/ttyS4",
                "/dev/ttyS5"
            ]
            self.device = Dobot(port=portArray[i], verbose=False)
            print("連接成功")
        except Exception as e:
            print("無法在" + portArray[i] + "連接Dobot\n原因:" + str(e))

            if (i < len(portArray) - 1):
                print("沒關係的別驚慌,我會嘗試連接下一個port\n")
                self._connect_dobot(i + 1)
            else:
                print("連接失敗,請檢查是否有將dobot接上USB")
Beispiel #8
0
def main():
    global bootOffset
    global nextBlue
    global nextOrange
    global tokensInPlay
    global orangeStorage
    global blueStorage
    global playArea

    if not simulate:
        port0 = list_ports.comports()[0].device
        device0 = Dobot(port=port0, verbose=True)
        (x1, y1, z1, r1, j1, j2, j3, j4) = device0.pose()
        bootOffset["x"] = x1
        bootOffset["y"] = y1
        bootOffset["z"] = z1

        # print(f'x:{x1} y:{y1} z:{z1} r:{0} j1:{j1} j2:{j2} j3:{j3} j4:{j4}')

        device0.speed(250, 250)
        device0.move_to(x1, y1, z1 - 1, 0, wait=False)
        device0.suck(True)
        device0.move_to(
            x1, y1, z1 + 20, 0, wait=False
        )  # we wait until this movement is done before continuing
        device0.move_to(
            x1 + 81.5, y1 - 94.5, z1 + 20, 0, wait=False
        )  # we wait until this movement is done before continuing
        device0.move_to(
            x1 + 81.5, y1 - 94.5, z1, 0, wait=False
        )  # we wait until this movement is done before continuing
        device0.suck(False)
        device0.move_to(
            x1 + 81.5, y1 - 94.5, z1 + 20, 0, wait=False
        )  # we wait until this movement is done before continuing
        device0.move_to(x1 - 36, y1 - 56, z1 + 20, 0, wait=False)

    try:
        os.remove("position_log.txt")
    except Exception as e:
        print("Exception while deleting file position_log.txt: " + str(e))

    # starting move to reposition home block from center of grid to last position of orange nest

    while (1):
        if (inputSource == "buttons"):
            if GPIO.input(button1) == 0:
                playStep("11")

            if GPIO.input(button2) == 0:
                playStep("12")

            if GPIO.input(button3) == 0:
                playStep("13")

            if GPIO.input(button4) == 0:
                playStep("21")

            if GPIO.input(button5) == 0:
                playStep("22")

            if GPIO.input(button6) == 0:
                playStep("23")

            if GPIO.input(button7) == 0:
                playStep("31")

            if GPIO.input(button8) == 0:
                playStep("32")

            if GPIO.input(button9) == 0:
                playStep("33")

        elif (inputSource == "console"):
            while True:
                consoleInput = ""
                while consoleInput == "":
                    consoleInput = ""
                    consoleInput = input(
                        "Select a position to place your token.  Use the number pad orientation:\n"
                    )
                    if len(consoleInput) == 1 and consoleInput.isdigit():
                        playStep(digitInputLookup[str(consoleInput)])
                    elif len(consoleInput) > 1:
                        print("Please enter only one position!")
                    elif not consoleInput.isdigit():
                        print("Please enter only one digit!")
Beispiel #9
0
def moveToken(sourceSpace, targetSpace, colorToMove, clearing=False):
    print("moveToken called with: {} {} {}".format(str(sourceSpace),
                                                   str(targetSpace),
                                                   str(colorToMove)))
    global tokensInPlay
    global playArea

    # use sourcePosition and targetPosition to lookup the xyz values to call with
    if not clearing:
        targetPosition = playArea[str(targetSpace)]
        sourcePosition = orangeStorage[str(
            sourceSpace)] if colorToMove == "orange" else blueStorage[str(
                sourceSpace)]
        playArea[str(targetSpace)].color = colorToMove
        tokensInPlay += 1
    else:
        sourcePosition = playArea[str(sourceSpace)]
        targetPosition = orangeStorage[str(
            targetSpace)] if colorToMove == "orange" else blueStorage[str(
                targetSpace)]
        playArea[str(sourceSpace)].color = "empty"
        tokensInPlay -= 1

    if simulate:
        print("Would move token color {} from {} to {}.".format(
            colorToMove.upper(), "({}, {})".format(str(sourcePosition.xPos),
                                                   str(sourcePosition.yPos)),
            "({}, {})".format(str(targetPosition.xPos),
                              str(targetPosition.yPos))))

    else:
        port0 = list_ports.comports()[0].device
        device0 = Dobot(port=port0, verbose=False)
        (x, y, z, r, j1, j2, j3, j4) = device0.pose()
        #file.write(datetime.datetime.now())
        # posLog("Button1")
        # posLog(f'{x - x1} {y - y1} {z - z1} {j1} \n')

        # pick up next orange piece (need to figure out how to find next) (pick up first orange)
        device0.move_to(bootOffset["x"] + sourcePosition.xPos,
                        bootOffset["y"] + sourcePosition.yPos,
                        bootOffset["z"] + 20,
                        0,
                        wait=True)
        device0.move_to(bootOffset["x"] + sourcePosition.xPos,
                        bootOffset["y"] + sourcePosition.yPos,
                        bootOffset["z"] - 1,
                        0,
                        wait=False)
        device0.suck(True)
        device0.move_to(bootOffset["x"] + sourcePosition.xPos,
                        bootOffset["y"] + sourcePosition.yPos,
                        bootOffset["z"] + 20,
                        0,
                        wait=False)

        # place piece in grid 1
        device0.move_to(bootOffset["x"] + targetPosition.xPos,
                        bootOffset["y"] + targetPosition.yPos,
                        bootOffset["z"] + 20,
                        0,
                        wait=False)
        device0.move_to(bootOffset["x"] + targetPosition.xPos,
                        bootOffset["y"] + targetPosition.yPos,
                        bootOffset["z"] - 1,
                        0,
                        wait=False)
        device0.suck(False)
        sleep(0.5)
        device0.move_to(
            bootOffset["x"] + targetPosition.xPos,
            bootOffset["y"] + targetPosition.yPos,
            bootOffset["z"] + 20,
            0,
            wait=True)  # we wait until this movement is done before continuing

        # go to neutral pose
        device0.move_to(bootOffset["x"] - 36,
                        bootOffset["y"] - 56,
                        bootOffset["z"] + 20,
                        0,
                        wait=True)
    elif (mode == 0):
        device.set_io_multiplexing(index, EIOMode.IO_FUNC_DUMMY)
        device.set_io_do(index, 0)
        return ("IO %d INPUT" % (index))


available_ports = []
for port in list_ports.comports():
    if (port.pid == 0x7523 and port.vid == 0x1a86):
        available_ports.append(port.device)

if len(available_ports) == 0:
    print("No Dobot found")
    exit()

device = Dobot(port=available_ports[0], verbose=False, skipInit=False)
device._get_device_version()
print(("Dobot device version: %d.%d.%d" %
       (device.majorVersion, device.minorVersion, device.revision)))
webRespDict["/version"] = (
    "Dobot device version: %d.%d.%d" %
    (device.majorVersion, device.minorVersion, device.revision))

webRespDict["/jog"] = jogMachine
webRespDict["/emotor"] = moveEMotor
webRespDict["/pose"] = getPose
webRespDict["/home"] = home
webRespDict["/moveinc"] = moveInc
webRespDict["/io"] = accessIOPorts

laserJig = LaserJig.LaserJig(device)
Beispiel #11
0
from serial.tools import list_ports

import util
from pydobot import Dobot

port = list_ports.comports()[0].device
device = Dobot(port=port, verbose=False)

util.pushCubeQueue(device)
device.close()
Beispiel #12
0
import time
from glob import glob

from pydobot import Dobot

available_ports = glob('/dev/cu*usb*')  # mask for OSX Dobot port
if len(available_ports) == 0:
    print('no port found for Dobot Magician')
    exit(1)

device = Dobot(port=available_ports[0])

time.sleep(0.5)
device.speed(100)
device.go(250.0, 0.0, 25.0)
device.speed(10)
device.go(250.0, 0.0, 0.0)
time.sleep(2)
device.close()
Beispiel #13
0
        print("menunggu koneksi")
        conn, client_address = sock.accept()
        global client_address
        global conn
        print('alamat : {}'.format(client_address))
        tersambung = False
        feedback("terhubung")  #---------->> TCP-IP

    if error == 0 or error == "EMG" or error == "":
        print("set port")
        try:
            avail_ports = setportlokal()
            print(avail_ports)
            if avail_ports != False:
                feedback("serial")  #------------>>Serial
                dobotkk = Dobot(avail_ports[0])
                print("kk")
                global dobotkk
                sendpose(1, 0)
                mainset = dobotPort(avail_ports[0], 1)
                print("mainset")
                global mainset
                jog = dobotPort(avail_ports[0], 2)
                print("jog")
                global jog
                mmove = manualmove(avail_ports[0])
                print("mmove")
                global move
                PTPm = PTP(avail_ports[0])
                print("ptpm")
                global PTPm
Beispiel #14
0
from serial.tools import list_ports

from pydobot import Dobot

port0 = list_ports.comports()[0].device

device = Dobot(port=port0, verbose=True)

while 1 < 2:
    (x, y, z, r, j1, j2, j3, j4) = device.pose()

    print(f'x:{x} y:{y} z:{z} j1:{j1} j2:{j2} j3:{j3} j4:{j4}')

    #device.speed(100, 100)
    #device.move_to(x + 20, y+20, z+20, r-20, wait=False)
    #device.suck(True)
    #device.move_to(x, y, z, r, wait=False)  # we wait until this movement is done before continuing
    #device.suck(False)

device.close()
Beispiel #15
0
#if psutil.OSX:
#    available_ports = glob('/dev/cu*usbserial*')  # mask for OSX Dobot port
#if psutil.LINUX:
#    available_ports = glob('/dev/ttyUSB*')  # mask for Linux Dobot port

available_ports = []
for port in list_ports.comports():
    if (port.pid == 0x7523 and port.vid == 0x1a86):
        available_ports.append(port.device)

if len(available_ports) == 0:
    print("No Dobot found")
    exit()

device = Dobot(port=available_ports[0], verbose=True)

device._get_device_version()

#test only
#device._set_end_effector_parameters(65) #paste dispenser
#device._get_end_effector_parameters()
#device._get_jog_joint_parameters()  #default: jog joint velocity 15.0, 15.0, 15.0, 30.0. jog joint acceleration 50.0, 50.0, 50.0, 50.0
#device._get_jog_coordinate_parameters() #default:jog coordinate velocity 60.0, 60.0, 60.0, 60.0. jog coordinate acceleration 60.0, 60.0, 60.0, 60.0
#device._set_jog_common_parameters(1.5,5.0)
#device._get_jog_common_parameters() #default jog velocityRatio:15.000 jog accelerationRatio:50.000

#device.set_arc_params(50,50);
#device.move_to(200,0,25,0, wait=True)
#device.arc_via_to(210,0,25,0,220,10,25,0, wait=True)
Beispiel #16
0
 def connect(self):
     port = list_ports.comports()[0].device
     self.rob = Dobot(port=port, verbose=True)
     self.set_speed(False)
     time.sleep(1.0)
     self.go_home(self.op_interval)
Beispiel #17
0
from serial.tools import list_ports

from pydobot import Dobot

port0 = list_ports.comports()[0].device
port1 = list_ports.comports()[1].device
device0 = Dobot(port=port0, verbose=True)


(x, y, z, r, j1, j2, j3, j4) = device0.pose()

print(f'x:{x} y:{y} z:{z} j1:{j1} j2:{j2} j3:{j3} j4:{j4}')

device1 = Dobot(port=port1, verbose=True)

(x, y, z, r, j1, j2, j3, j4) = device1.pose()

print(f'x:{x} y:{y} z:{z} j1:{j1} j2:{j2} j3:{j3} j4:{j4}')

device0.home(True)


device0.close()
device1.close()
Beispiel #18
0
 def __init__(self):
     port = list_ports.comports()[0].device
     self.device = Dobot(port=port, verbose=False)
Beispiel #19
0
"""@Author: Sameer Kesava"""

from google import auth  #for authorization
import os
import time
import dialogflow  #Google Natural Language Processing API
from pydobot import Dobot  # Dobot

serial_port = input('Enter the serial port connecting the Dobot: ')

dobot = Dobot(port=serial_port)

# Set the speed of the Dobot
speed = 100
dobot.speed(speed)

json_file = input('Enter path to the json credentials file: ')

#Authorization to login to the project chosen during gcloud init
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = json_file

credentials, project = auth.default()

#Creating a session using the credentials
session_client = dialogflow.SessionsClient(credentials=credentials)

session_ID = input('Enter a name for session id: ')

#Final step setting up a session
session = session_client.session_path(project, session_ID)
Beispiel #20
0
from board import *
from utils import *
import time
import cv2
import vision

from pydobot import Dobot

# 连接机械臂
global device
device = Dobot(port='com6', verbose=False)
time.sleep(0.5)
device.speed(1)
device._get_pose()

# 位置初始化
device.go_init_pos()


def text_objects(text, font):
    textSurface = font.render(text, True, black)
    return textSurface, textSurface.get_rect()


def message_display(text, x, y, size):
    largeText = pygame.font.Font('freesansbold.ttf', size)
    TextSurf, TextRect = text_objects(text, largeText)
    TextRect.center = (x, y)
    screen.blit(TextSurf, TextRect)

    pygame.display.update()
Beispiel #21
0
# Copyright (c) 2020 Sagar Gubbi. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from pydobot import Dobot

d = Dobot(port='/dev/ttyUSB0', verbose=False)

d.wait_for_cmd(d.home())

d.close()


Beispiel #22
0
 def __init__(self, port):
     self.device = Dobot(port=port, verbose=True)
     self.home_x = 200
     self.home_y = 0
     self.home_z = 135
Beispiel #23
0
 def __init__(self):
     self.port = list_ports.comports()[0].device
     self.device = Dobot(port=self.port, verbose=True)
     self.device.speed(100,100)