-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwelding_test.py
51 lines (41 loc) · 1.78 KB
/
welding_test.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
from robolink import * # API to communicate with RoboDK for simulation and offline/online programming
from robodk import * # Robotics toolbox for industrial robots(TCP welding)
# Any interaction with RoboDK must be done through RDK:
RDK = Robolink()
# Select a robot (popup is displayed if more than one robot is available)
robot = RDK.ItemUserPick('Select a robot', ITEM_TYPE_ROBOT)
if not robot.Valid():
raise Exception('No robot selected or available')
# get the current position of the TCP with respect to the reference frame:
# (4x4 matrix representing position and orientation)
target_ref = robot.Pose()
pos_ref = target_ref.Pos()
print("Drawing a polygon around the target: ")
print(Pose_2_TxyzRxyz(target_ref))
robot.MoveJ(target_ref) #first point
# It is important to provide the reference frame and the tool frames when generating programs offline
robot.setPoseFrame(robot.PoseFrame())
robot.setPoseTool(robot.PoseTool())
robot.setZoneData(10) # rounding parameter (Also known as: CNT, APO/C_DIS, ZoneData, Blending radius, cornering, ...)
robot.setSpeed(200) # Linear speed
n_sides = 6
R = 100
# make a hexagon around reference target:
for i in range(n_sides+1):
ang = i*2*pi/n_sides #angle: 0, 60, 120, ...
#-----------------------------
# Movement relative to the reference frame
# Create a copy of the target
target_i = Mat(target_ref)
pos_i = target_i.Pos()
pos_i[0] = pos_i[0] + R*cos(ang)
pos_i[1] = pos_i[1] + R*sin(ang)
target_i.setPos(pos_i)
print("Moving to target %i: angle %.1f" % (i, ang*180/pi))
print(str(Pose_2_TxyzRxyz(target_i)))
robot.MoveL(target_i)
target_i = target_ref * rotz(ang) * transl(R,0,0) * rotz(-ang)
robot.MoveL(target_i)
# move back to the center, then home:
robot.MoveL(target_ref)
print('Done')