-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDobot3DPrinting.py
63 lines (47 loc) · 1.99 KB
/
Dobot3DPrinting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import DobotDllType as dType
from moveDobot import moveJoint
import os
api = dType.load()
current_path = os.path.dirname(__file__)
CON_STR = {
dType.DobotConnect.DobotConnect_NoError: "DobotConnect_NoError",
dType.DobotConnect.DobotConnect_NotFound: "DobotConnect_NotFound",
dType.DobotConnect.DobotConnect_Occupied: "DobotConnect_Occupied"}
state = dType.ConnectDobot(api, "COM6", 115200)[0]
print("Connect status:", CON_STR[state])
if state == dType.DobotConnect.DobotConnect_NoError:
# Homing
print("Home...")
dType.SetHOMEParams(api, 250, 0, 40, 0, isQueued=0)
dType.SetHOMECmd(api, temp=0, isQueued=0)
# Adjusts the speed and acceleration of the joints for printing
dType.SetPTPJointParams(api, 50, 10, 50, 10, 50, 10, 50, 10, 0)
# I/O Interface is configured
dType.SetIOMultiplexing(api, 10, 1, 0)
dType.SetIOMultiplexing(api, 11, 2, 0)
dType.SetIOMultiplexing(api, 12, 1, 0)
dType.dSleep(100)
dType.SetIODO(api, 10, 1, 0)
dType.SetIODO(api, 12, 1, 0)
dType.dSleep(100)
# Material extrusion begins
dType.SetEMotor(api, 0, 1, 180, 0)
dType.dSleep(100)
# Enter the path of the flat surface to be printed
print_type = os.path.join(current_path, "data_non_planar")
data_path = os.path.join(print_type, "data9")
output_path = os.path.join(data_path, "output")
file_name = os.path.join(output_path, "angle_values.txt")
print(f"Printing :{file_name}")
with open(file_name, 'r') as file:
next(file)
for line in file:
angles = line.split()
moveJoint(float(angles[0]), float(angles[1]), float(angles[2]), float(angles[3]), float(angles[4]))
lastPosition = dType.GetPose(api)
dType.SetPTPCmdEx(api, 2, lastPosition[0], lastPosition[1], lastPosition[2]+3, lastPosition[3], 0)
# I/O interface is switched off and extrusion is stopped
dType.SetIODO(api, 10, 0, 0)
dType.SetIODO(api, 12, 0, 0)
dType.SetEMotorS(api, 0, 0, 0, 0, 0)
dType.DisconnectDobot(api)