def __init__( self, home=(220.0, 0.0, 135.0, 9.0), port=None, verbose=False ): assert len(home) == 4 self.home = home if port is None: port = list_ports.comports()[0].device self.device = Dobot(port=port, verbose=verbose)
''' from dobot import Dobot import time # The top Z to go to. up = 100 # The bottom Z to go to. down = 55 # Maximum speed in mm/s speed = 400 # Acceleration in mm/s^2 acceleration = 300 dobot = Dobot('COM4', debug=True) # Enable calibration routine if you have a limit switch/photointerrupter installed on the arm. # See example-switch.py for details. # Move both arms to approximately 45 degrees. # Re-initialize accelerometers at approx. 45 degrees for the best result. Available on RAMPS only. # dobot.MoveWithSpeed(260.0, 0.0, 85, 700, acceleration) # time.sleep(2) # dobot.InitializeAccelerometers() # dobot.CalibrateJoint(1, dobot.freqToCmdVal(2000), dobot.freqToCmdVal(50), 1, 5, 1, 0) # Line # dobot.MoveWithSpeed(200.0, 80.0, up, speed, acceleration) # dobot.MoveWithSpeed(200.0, 80.0, down, speed, acceleration) # dobot.MoveWithSpeed(200.0, -90.0, down, speed, acceleration)
from dobot import Dobot import time # The top Z to go to. up = 50 # The bottom Z to go to. down = 50 # Maximum speed in mm/s speed = 400 # Acceleration in mm/s^2 acceleration = 300 # dobot = Dobot('/dev/tty.usbmodem1421', debug=True, fake=True) # dobot = Dobot('COM4', debug=True) dobot = Dobot('/dev/tty.usbmodem1421', debug=True) # Enable calibration routine if you have a limit switch/photointerrupter installed on the arm. # See example-switch.py for details. # Move both arms to approximately 45 degrees. # Re-initialize accelerometers at approx. 45 degrees for the best result. Available on RAMPS only. # dobot.MoveWithSpeed(260.0, 0.0, 85, 700, acceleration) # time.sleep(2) # dobot.InitializeAccelerometers() # dobot.CalibrateJoint(1, dobot.freqToCmdVal(2000), dobot.freqToCmdVal(50), 1, 5, 1, 0) # Line # dobot.MoveWithSpeed(200.0, 80.0, up, speed, acceleration) # dobot.MoveWithSpeed(200.0, 80.0, down, speed, acceleration) # dobot.MoveWithSpeed(200.0, -90.0, down, speed, acceleration)
#! /usr/bin/env python import time from dobot import Dobot dobot = Dobot('COM5', debug=True) # Acceleration in mm/s^2 acceleration = 50 speed = 50 #go home #raw_input("Press Enter to go home...") #dobot.MoveWithSpeed(140, -200, 80, speed, acceleration) dobot.MoveWithSpeed(140, -210, 200, speed, acceleration)
#! /usr/bin/env python ''' Laser going in a straight line. !!!!! TAKE ALL POSSIBLE PRECAUTIONS TO PREVENT FIRE !!!!! !!!!! BE READY TO DISCONNECT THE ARM FROM POWER SOURCE AT ANY TIME !!!!! ''' from dobot import Dobot import time # dobot = Dobot('COM4', debug=True) dobot = Dobot('/dev/ttyUSB0', debug=True) # Enable calibration routine if you have a limit switch/photointerrupter installed on the arm. # See example-switch.py for details. # Move both arms to approximately 45 degrees. # dobot.MoveWithSpeed(260.0, 0.0, 85, 700) # time.sleep(2) # dobot.CalibrateJoint(1, dobot.freqToCmdVal(2000), dobot.freqToCmdVal(50), 1, 5, 1, 0) def repeatUntilQueued(on): ret = (0, 0) while not ret[0] or not ret[1]: ret = dobot.LaserOn(on) dobot.MoveWithSpeed(200.0, -50.0, 100.0, 50) repeatUntilQueued(True)
from dobot import Dobot from rosdobot.srv import * from threading import Thread import rospy import sys if (len(sys.argv) == 1): print "USAGE [PORT directory]" sys.exit(1) port = sys.argv[1] available_ports = glob(port) if (len(available_ports) == 0): print('no port found for Dobot Magician') exit(1) device = Dobot(port=available_ports[0]) #test function def setStartPose(): time.sleep(0.5) device.speed(100) device.go(150.0, 0.0, 10.0) device.speed(10) time.sleep(2) #ptp thread and handler def handler_setPTPCMD(req): device.go(req.x, req.y, req.z, req.r) return setPTPCMDResponse(True)
class Arm: def __init__( self, home=(220.0, 0.0, 135.0, 9.0), port=None, verbose=False ): assert len(home) == 4 self.home = home if port is None: port = list_ports.comports()[0].device self.device = Dobot(port=port, verbose=verbose) @property def position(self): return self.device.pose()[:4] def go_home(self): self.device.wait_for_cmd(self.device.move_to(*self.home)) def reset_home(self): self.device.wait_for_cmd(self.device.home()) self.go_home() def grip(self, toggle: bool): self.device.wait_for_cmd(self.device.grip(toggle)) def grab(self, x, y, angle, deep=False): self.grip(False) # horizontal move to target self.device.wait_for_cmd( self.device.move_to(x, y, self.home[2], self.home[3]) ) # go down if deep: self.device.wait_for_cmd( self.device.move_to(x, y, -25, self.home[3]) ) else: self.device.wait_for_cmd( self.device.move_to(x, y, -25, self.home[3]) ) # and grip self.grip(True) time.sleep(1) self.go_home() self.grip(False)
#! /usr/bin/env python ''' Laser going in a straight line. !!!!! TAKE ALL POSSIBLE PRECAUTIONS TO PREVENT FIRE !!!!! !!!!! BE READY TO DISCONNECT THE ARM FROM POWER SOURCE AT ANY TIME !!!!! ''' from dobot import Dobot import time # dobot = Dobot('COM4', debug=True) dobot = Dobot('/dev/tty.usbmodem1421', debug=True) # Enable calibration routine if you have a limit switch/photointerrupter installed on the arm. # See example-switch.py for details. # Move both arms to approximately 45 degrees. # dobot.MoveWithSpeed(260.0, 0.0, 85, 700) # time.sleep(2) # dobot.CalibrateJoint(1, dobot.freqToCmdVal(2000), dobot.freqToCmdVal(50), 1, 5, 1, 0) def repeatUntilQueued(on): ret = (0, 0) while not ret[0] or not ret[1]: ret = dobot.LaserOn(on) dobot.MoveWithSpeed(200.0, -50.0, 100.0, 50) repeatUntilQueued(True)
to execute until the queue (200 commands) is empty. """ import math from dobot import Dobot import time import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox from PyQt5 import uic # Maximum speed in mm/s speed = 80 # Acceleration in mm/s^2 acceleration = 80 dobot = Dobot('COM17', debug=False, plot=True, rate=115200) print("Turn ON!") """ # This loads the GUI from the .ui file that is created by QtDesigner. The .ui file should be in the same folder as this # python file (or specify different path). Ui_MainWindow, QtBaseClass = uic.loadUiType('DobotMainUi.ui') # Here, a class is defined to represent the entire GUI. It is derived from a Qt class named QMainWindow, which # corresponds to the GUI type specified in QtDesigner. All of the functional aspects (as opposed to design aspects) of # the GUI are defined in this class. For example, what happens when a user presses a button. class DobotGUIApp(QMainWindow): # class initialization function (initialize the GUI) def __init__(self, parent=None): # I'm a python noob, but I'm guessing this means initialize the parent class. I imagine all the super classes # have to be explicitly initialized.
from dobot import Dobot import time # The top Z to go to. up = 180 # The bottom Z to go to. down = 120 # Maximum speed in mm/s speed = 700 # Acceleration in mm/s^2 acceleration = 400 # dobot = Dobot('/dev/tty.usbmodem1421', debug=True, fake=True) # dobot = Dobot('COM4', debug=True) dobot = Dobot('/dev/ttyUSB0', debug=True) # Enable calibration routine if you have a limit switch/photointerrupter installed on the arm. # See example-switch.py for details. # Take the tool to a safe height. # dobot.MoveWithSpeed(260.0, 0.0, up, speed, acceleration) # time.sleep(2) # dobot.CalibrateJoint(1, dobot.freqToCmdVal(2000), dobot.freqToCmdVal(50), 1, 5, 1, 0) dobot.Gripper(480) # Take an object on the right and put to the left dobot.MoveWithSpeed(260.0, 0.0, up, speed, acceleration, 0) dobot.MoveWithSpeed(260.0, -70.0, up, speed, acceleration) dobot.MoveWithSpeed(260.0, -70.0, down, speed, acceleration) dobot.Gripper(208)
#! /usr/bin/env python ''' Take an object using sucker pump and put it in a different place. ''' from dobot import Dobot import time dobot = Dobot('COM3', debug=True) #dobot = Dobot('/dev/tty.usbmodem1421', debug=True) # Enable calibration routine if you have a limit switch/photointerrupter installed on the arm. # See example-switch.py for details. # Take the tool to a safe height. # dobot.MoveWithSpeed(260.0, 0.0, 180, 700) # time.sleep(2) # dobot.CalibrateJoint(1, dobot.freqToCmdVal(2000), dobot.freqToCmdVal(50), 1, 5, 1, 0) def repeatUntilQueued(on): ret = (0, 0) while not ret[0] or not ret[1]: ret = dobot.PumpOn(on) ret = (0, 0) while not ret[0] or not ret[1]: ret = dobot.ValveOn(on) dobot.MoveWithSpeed(200.0, -50.0, 180.0, 100)
from dobot import Dobot # Acceleration in mm/s^2 acceleration = 20 speed = 20 dobot = Dobot('COM5', debug=False) dobot.CalibrateJoint(1, dobot.freqToCmdVal(500), dobot.freqToCmdVal(50), 1, 5, 1, 0) dobot.InitializeAccelerometers() #=============================================================================== # dobot = Dobot('COM5', debug=True) # dobot.CalibrateJoint(1, dobot.freqToCmdVal(500), dobot.freqToCmdVal(50),1 , 5, 1, 0) # dobot.InitializeAccelerometers() #=============================================================================== #dobot.MoveWithSpeed(260, -10, 80, speed, acceleration) #go home #raw_input("Press Enter to go home...") dobot.MoveWithSpeed(240, -20, 80, speed, acceleration)