-
Notifications
You must be signed in to change notification settings - Fork 1
/
cycle_time.py
32 lines (24 loc) · 1.26 KB
/
cycle_time.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
from robolink import * # RoboDK API
RDK = Robolink()
program = RDK.ItemUserPick('Select a program (make sure the program does not change the robot speed)', ITEM_TYPE_PROGRAM)
# Retrieve the robot linked to the selected program
robot = program.getLink(ITEM_TYPE_ROBOT)
# Output the linear speed, joint speed and time (separated by tabs)
writeline = "Linear Speed (mm/s)\tJoint Speed (deg/s)\tCycle Time(s)"
print(writeline)
# Prepare an HTML message we can show to the user through the RoboDK API:
msg_html = "<table border=1><tr><td>"+writeline.replace('\t','</td><td>')+"</td></tr>"
for speed_lin in [1, 5, 10, 20, 50, 100, 200, 500]:
for speed_joints in [1, 5, 10, 20, 50, 100, 200, 500]:
# Set the robot speed
robot.setSpeed(speed_lin, speed_joints)
# Update the program and retrieve updated information:
# https://robodk.com/doc/en/PythonAPI/robolink.html#robolink.Item.Update
result = program.Update()
instructions, time, travel, ok, error = result
# Print the information
newline = "%.1f\t%.1f\t%.1f" % (speed_lin, speed_joints, time)
print(newline)
msg_html = msg_html + '<tr><td>' + newline.replace('\t','</td><td>') + '</td></tr>'
msg_html = msg_html + '</table>'
RDK.ShowMessage(msg_html)