-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharm_plot.py
65 lines (47 loc) · 1.76 KB
/
arm_plot.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
64
65
from xarm.wrapper import XArmAPI
import numpy as np
Z_DRAW = 0 # Draw height (mm)
Z_MOVE = 5 # Jog height (mm)
MOVE_SPEED = 80 # mm/s
DRAW_SPEED = 30 # mm/s
PEN_DIAMETER = 8 # mm
arm = XArmAPI('192.168.1.205') # Arm is named arm
arm.motion_enable(enable=True)
arm.set_mode(0)
arm.set_state(state=0)
# accounting for 8 mm thick base arm is mounted to
arm.set_world_offset([-260, 0, 8, 0, 0, 0])
# pen tip position relative to center of mount
arm.set_tcp_offset([42.75 + np.sqrt(2)*(PEN_DIAMETER/2), 0, 97, 0, 0, 0])
arm.set_state(state=0)
arm.set_position(z=Z_MOVE)
# moves down to pen
arm.set_position(x=0, y=0, z=0.5, roll=180, pitch=0,
yaw=0, speed=20, wait=True)
# insert pen here!!
input('Insert the pen and press enter!')
# continue
arm.set_position(z=10, speed=5, wait=True)
moves = np.genfromtxt('commands.csv', delimiter=',')
positions = np.array([[0, 0, Z_MOVE, MOVE_SPEED]])
for move in moves:
if move[0] == 0:
positions = np.append(
positions, [[move[2], move[1], Z_MOVE, MOVE_SPEED]], axis=0)
positions = np.append(
positions, [[move[2], move[1], Z_DRAW, DRAW_SPEED]], axis=0)
elif move[0] == 1:
positions = np.append(
positions, [[move[2], move[1], Z_DRAW, DRAW_SPEED]], axis=0)
elif move[0] == 2:
positions = np.append(
positions, [[move[2], move[1], Z_DRAW, DRAW_SPEED]], axis=0)
positions = np.append(
positions, [[move[2], move[1], Z_MOVE, DRAW_SPEED]], axis=0)
else:
print('uh oh')
for coords in positions:
# With radius and no wait
arm.set_position(*coords[0:3], speed=coords[3], radius=-1, wait=True)
# No wait, with radius
# arm.set_position(*coords[0:3], speed = coords[3], radius = 0.2, wait=False)