-
Notifications
You must be signed in to change notification settings - Fork 0
/
motor_movements.py
254 lines (209 loc) · 8.77 KB
/
motor_movements.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
"""
This set of functions is written to make the movements more akin to natural language.
See the definitions of motors in:
global_motor_definitions.py
and the help in
gantry_help.py
in particular, from help_reference():
X = 5, Coordinate System: 3, units: microns
Y = 6, Coordinate system: 3 units: microns
Z = Z, Coordinate system: 1, moves the RTT stage up and down, units: microns
Roll = A, Coordinate System: 1, tips the RTT stage towards front or back, i.e. rotation around X axis, units: degrees
Pitch = B, Coordinate System: 1, tilts the RTT stage towards left and right, Rotation around Y axis, units: degrees
Rot = C, Coordinate System: 2, rotation around Z axis, units: degrees
All motions are in linear mode, i.e. slow, by default, unless specified explicitly by the function call.
Author M. Altissimo c/o Elettra Sincrotrone Trieste SCpA
"""
#(shell, axis, speed, mode, length)
"""
relative motions
"""
#X axis, CS 3, units: microns
def left (shell, length, mode= "inc", speed = "linear"):
"""
Moves the X head carriage to the left, i.e. positive relative motion.
:param shell: required and active, an SSH shell for comms
:param speed: linear (i.e. slow) by default. Can be set to rapid
:param mode: absolute (abs) or relative (inc), set to inc by default
:param length: length of motion in microns
:return:
"""
move = "&3 cpx " + mode + " " + speed + "X" +str(length) +"\n"
shell.send(move)
return()
def right (shell, length, mode= "inc", speed = "linear"):
"""
Moves the X head carriage to the right, i.e. negative relative motion
:param shell: required and active, an SSH shell for comms
:param speed: linear (i.e. slow) by default. Can be set to rapid
:param mode: absolute (abs) or relative (inc), set to inc by default
:param length: length of motion in microns. The function makes it negative.
:return:
"""
move = "&3 cpx " + mode + " " + speed + "X" + str(-length) + "\n"
shell.send(move)
return()
#Y axis, CS 3, units:microns
def forward (shell, length, mode= "inc", speed = "linear"):
"""
Moves the RTT stage foward, i.e. positive relative motion
:param shell: required and active, an SSH shell for comms
:param speed: linear (i.e. slow) by default. Can be set to rapid
:param mode: absolute (abs) or relative (inc), set to inc by default
:param length: length of motion in microns.
:return:
"""
move = "&3 cpx " + mode + " " + speed + "Y" + str(length) + "\n"
shell.send(move)
return ()
def back (shell, length, mode= "inc", speed = "linear"):
"""
Moves the RTT stage back, i.e. negative relative motion
:param shell: required and active, an SSH shell for comms
:param speed: linear (i.e. slow) by default. Can be set to rapid
:param mode: absolute (abs) or relative (inc), set to inc by default
:param length: length of motion in microns. The function makes it negative
:return:
"""
move = "&3 cpx " + mode + " " + speed + "Y" + str(-length) + "\n"
shell.send(move)
return ()
#Z axis, CS 2, units: microns
def up (shell, length, mode= "inc", speed = "linear"):
"""
Moves the RTT stage up, i.e. relative positive motion
:param shell: required and active, an SSH shell for comms
:param speed: linear (i.e. slow) by default. Can be set to rapid
:param mode: absolute (abs) or relative (inc), set to inc by default
:param length: length of motion in microns.
:return:
"""
move = "&2 cpx " + mode + " " + speed + "Z" + str(length) + "\n"
shell.send(move)
return()
def down (shell, length, mode= "inc", speed = "linear"):
"""
Moves the RTT stage down, i.e. relative positive motion
:param shell: required and active, an SSH shell for comms
:param speed: linear (i.e. slow) by default. Can be set to rapid
:param mode: absolute (abs) or relative (inc), set to inc by default
:param length: length of motion in microns. The function makes it negative
:return:
"""
move = "&2 cpx " + mode + " " + speed + "Z" + str(-length) + "\n"
shell.send(move)
return()
#Rotation axis, CS 2, units: degrees
def rot_cwise (shell, length, mode= "inc", speed = "linear"):
"""
Rotation of the RTT stage, clockwise, units in degrees/
:param shell: required and active, an SSH shell for comms
:param speed: linear (i.e. slow) by default. Can be set to rapid
:param mode: absolute (abs) or relative (inc), set to inc by default
:param length: length of motion in degrees. The function makes it negative, as that's the clockwise direction.
:return:
"""
rot = "&1 cpx " + mode + " " + speed + "C" + str(-length) + "\n"
shell.send(rot)
return()
def rot_ccwise (shell, length, mode= "inc", speed = "linear"):
"""
Rotation of the RTT stage, counterclockwise, units in degrees/
:param shell: required and active, an SSH shell for comms
:param speed: linear (i.e. slow) by default. Can be set to rapid
:param mode: absolute (abs) or relative (inc), set to inc by default
:param length: length of motion in degrees.
:return:
"""
rot = "&1 cpx " + mode + " " + speed + "C" + str(length) + "\n"
shell.send(rot)
return()
#A and B axes, rolls and pitche respetively, CS1, units: degrees
def pitchup (shell, length, mode= "inc", speed = "linear"):
"""
Tilts the RTT stage towards left, Rotation around Y axis, units: degrees
:param shell: required and active, an SSH shell for comms
:param speed: linear (i.e. slow) by default. Can be set to rapid
:param mode: absolute (abs) or relative (inc), set to inc by default
:param length:length of motion in degrees.
:return:
"""
pitch = "&1 cpx " + mode + " " + speed + "B" + str(length) + "\n"
shell.send(pitch)
return()
def pitchdown (shell, length, mode= "inc", speed = "linear"):
"""
Tilts the RTT stage towards right, Rotation around Y axis, units: degrees
:param shell: required and active, an SSH shell for comms
:param speed: linear (i.e. slow) by default. Can be set to rapid
:param mode: absolute (abs) or relative (inc), set to inc by default
:param length:length of motion in degrees.
:return:
"""
pitch = "&1 cpx " + mode + " " + speed + "B" + str(-length) + "\n"
shell.send(pitch)
return ()
def roll_left (shell, length, mode= "inc", speed = "linear"):
"""
Tips the RTT stage towards front , i.e. rotation around X axis, units: degrees
:param shell: required and active, an SSH shell for comms
:param speed: linear (i.e. slow) by default. Can be set to rapid
:param mode: absolute (abs) or relative (inc), set to inc by default
:param length:length of motion in degrees.
:return:
"""
roll = "&1 cpx " + mode + " " + speed + "A" + str(length) + "\n"
shell.send(roll)
return()
def roll_right (shell, length, mode= "inc", speed = "linear"):
"""
Tips the RTT stage towards front , i.e. rotation around X axis, units: degrees
:param shell: required and active, an SSH shell for comms
:param speed: linear (i.e. slow) by default. Can be set to rapid
:param mode: absolute (abs) or relative (inc), set to inc by default
:param length:length of motion in degrees.
:return:
"""
roll = "&1 cpx " + mode + " " + speed + "A" + str(-length) + "\n"
shell.send(roll)
return()
def kill(shell):
"""
Command to kill all movements at once.
:param shell: a paramiko shell to the pmac
:return:
"""
shell.send("&*abort\n")
return()
def get_jogspeed(shell, axis):
"""
Gets from the system the jogspeed for the specified axis
the user can input in normal x,y,z, pitch, roll, rot | yaw
:param shell: a shell connection to the pmac
:param axis: the axis for which the jogspeed is required
:return: jogspeed, the programmed jogspeed
"""
# TODO disable echoing, so as to return only one value, see Pmac user and software manual (page 1154)
# go on the machine, check with echo what the output is, then set the echo bit according to that, so as to get a response
# like:
# Motor[1].JogSpeed
# 8900
new_ax = axis_conversion(axis)
shell.send("Motor[", new_ax, "].JogSpeed")
out = listen(shell)
jogspeed = get_value(out)
return (jogspeed)
def set_jogspeed(shell, axis, value):
"""
Sets the jog speed of the specified axis, and prints it out for checking by the user
:param shell: a shell connection tothe
:param axis: the axis for which the jogspeed is required
:param speed: desired jogspeed
:return
"""
new_ax = axis_conversion(axis)
shell.send("Motor[", new_ax, "].JogSpeed=", value)
newspeed = get_jogspeed(shell, axis)
output = ""
output += "The new jogspeed has been set to: " + str(newspeed)
return (output)