Based on Communication Protocol V1.1.4 (latest version here)
pip install pydobot
from serial.tools import list_ports
from pydobot import Dobot
port = list_ports.comports()[0].device
device = Dobot(port=port, verbose=True)
(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.move_to(x + 20, 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()
-
Dobot(port, verbose=False) Creates an instance of dobot connected to given serial port.
- port: string with name of serial port to connect
- verbose: bool will print to console all serial comms
-
.pose() Returns the current pose of dobot, as a tuple (x, y, z, r, j1, j2, j3, j4)
- x: float current x cartesian coordinate
- y: float current y cartesian coordinate
- z: float current z cartesian coordinate
- r: float current effector rotation
- j1: float current joint 1 angle
- j2: float current joint 2 angle
- j3: float current joint 3 angle
- j4: float current joint 4 angle
-
.move_to(x, y, z, r, wait=False) queues a translation in dobot to given coordinates
- x: float x cartesian coordinate to move
- y: float y cartesian coordinate to move
- z: float z cartesian coordinate to move
- r: float r effector rotation
- wait: bool waits until command has been executed to return to process
-
.speed(velocity, acceleration) changes velocity and acceleration at which the dobot moves to future coordinates
- velocity: float desired translation velocity
- acceleration: float desired translation acceleration
-
.suck(enable)
- enable: bool enables/disables suction
-
.grip(enable)
- enable: bool enables/disables gripper
-
.wait(ms)
- ms: integer milliseconds to wait before the next command
- wait: bool waits until command has been executed to return to process
-
.start_stepper(pps, motor=0, wait=False)
- pps: integer pulses per second sent to e-motor (0 or 1)
- motor: integer position of the e-motor
- wait: bool waits until command has been executed to return to process
-
.stop_stepper(motor=0, wait=False)
- motor: integer position of the e-motor (0 or 1)
- wait: bool waits until command has been executed to return to process
-
.start_conveyor(speed, motor=0, wait=False)
- speed: float speed in m/s
- motor: integer position of the conveyor belt (0 or 1)
- wait: bool waits until command has been executed to return to process
-
.set_io_mode(address, mode, wait=False)
- address: integer EIO port number
- mode: str I/O mode (Dummy, PWM, DO, DI, ADC)
- wait: bool waits until command has been executed to return to process
-
.set_pwm_output(address, frequency, duty_cycle, wait=False)
- address: integer EIO port number
- frequency: float pulse frequency
- duty_cycle: float pulse duty cycle (0 to 100)
- wait: bool waits until command has been executed to return to process