UC2-REST 0.2.0.11__tar.gz → 0.2.0.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/PKG-INFO +1 -1
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/UC2_REST.egg-info/PKG-INFO +1 -1
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/__version__.py +1 -1
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/motor.py +37 -42
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/LICENSE +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/README.md +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/UC2_REST.egg-info/SOURCES.txt +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/UC2_REST.egg-info/dependency_links.txt +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/UC2_REST.egg-info/not-zip-safe +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/UC2_REST.egg-info/requires.txt +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/UC2_REST.egg-info/top_level.txt +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/setup.cfg +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/setup.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/UC2Client.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/__init__.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/analog.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/camera.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/config.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/config_.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/digitalout.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/galvo.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/home.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/laser.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/ledmatrix.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/logger.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/modules.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/mserial.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/pid.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/slm.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/state.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/updater.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/utils.py +0 -0
- {UC2 REST-0.2.0.11 → UC2 REST-0.2.0.12}/uc2rest/wifi.py +0 -0
|
@@ -6,7 +6,7 @@ __version__.py
|
|
|
6
6
|
|
|
7
7
|
__title__ = 'UC2 REST'
|
|
8
8
|
__description__ = 'This pacage will help you to drive the ESP32-driven microscopy control modules from UC2'
|
|
9
|
-
__version__ = "v0.2.0.
|
|
9
|
+
__version__ = "v0.2.0.12"
|
|
10
10
|
__author__ = 'Benedict Diederich'
|
|
11
11
|
__author_email__ = 'benedictdied@gmail.com'
|
|
12
12
|
__license__ = 'GPL v3'
|
|
@@ -3,7 +3,7 @@ import time
|
|
|
3
3
|
import json
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
gTIMEOUT =
|
|
6
|
+
gTIMEOUT = 100 # seconds to wait for a response from the ESP32
|
|
7
7
|
class Motor(object):
|
|
8
8
|
|
|
9
9
|
# indicate if there is any motion happening
|
|
@@ -97,27 +97,27 @@ class Motor(object):
|
|
|
97
97
|
y1 = (x-y)/np.sqrt(2)
|
|
98
98
|
return x1, y1
|
|
99
99
|
|
|
100
|
-
def move_x(self, steps=0, speed=1000, is_blocking=False, is_absolute=False, is_enabled=True, timeout=gTIMEOUT):
|
|
100
|
+
def move_x(self, steps=0, speed=1000, acceleration=None, is_blocking=False, is_absolute=False, is_enabled=True, timeout=gTIMEOUT):
|
|
101
101
|
if self.isCoreXY:
|
|
102
102
|
# have to turn two motors to move in X direction
|
|
103
103
|
xTemp, yTemp = self.cartesian2corexy(steps, 0)
|
|
104
104
|
return self.move_xy(steps=(xTemp, yTemp), speed=(speed,speed), is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
105
105
|
else:
|
|
106
|
-
return self.move_axis_by_name(axis="X", steps=steps, speed=speed, is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
106
|
+
return self.move_axis_by_name(axis="X", steps=steps, speed=speed, acceleration=acceleration, is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
107
107
|
|
|
108
|
-
def move_y(self, steps=0, speed=1000, is_blocking=False, is_absolute=False, is_enabled=True, timeout=gTIMEOUT):
|
|
108
|
+
def move_y(self, steps=0, speed=1000, acceleration=None, is_blocking=False, is_absolute=False, is_enabled=True, timeout=gTIMEOUT):
|
|
109
109
|
if self.isCoreXY:
|
|
110
110
|
# have to turn two motors to move in Y direction
|
|
111
111
|
xTemp, yTemp = self.cartesian2corexy(0,steps)
|
|
112
112
|
return self.move_xy(steps=(xTemp, yTemp), speed=(speed,speed), is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
113
113
|
else:
|
|
114
|
-
return self.move_axis_by_name(axis="Y", steps=steps, speed=speed, is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
114
|
+
return self.move_axis_by_name(axis="Y", steps=steps, speed=speed, acceleration=acceleration, is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
115
115
|
|
|
116
|
-
def move_z(self, steps=0, speed=1000, is_blocking=False, is_absolute=False, is_enabled=True, timeout=gTIMEOUT):
|
|
117
|
-
return self.move_axis_by_name(axis="Z", steps=steps, speed=speed, is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
116
|
+
def move_z(self, steps=0, speed=1000, acceleration=None, is_blocking=False, is_absolute=False, is_enabled=True, timeout=gTIMEOUT):
|
|
117
|
+
return self.move_axis_by_name(axis="Z", steps=steps, speed=speed, acceleration=acceleration, is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
118
118
|
|
|
119
|
-
def move_t(self, steps=0, speed=1000, is_blocking=False, is_absolute=False, is_enabled=True, timeout=gTIMEOUT):
|
|
120
|
-
return self.move_axis_by_name(axis="T", steps=steps, speed=speed, is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
119
|
+
def move_t(self, steps=0, speed=1000, acceleration=None, is_blocking=False, is_absolute=False, is_enabled=True, timeout=gTIMEOUT):
|
|
120
|
+
return self.move_axis_by_name(axis="T", steps=steps, speed=speed, acceleration=acceleration, is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
121
121
|
|
|
122
122
|
def move_xyz(self, steps=(0,0,0), speed=(1000,1000,1000), is_blocking=False, is_absolute=False, is_enabled=True, timeout=gTIMEOUT):
|
|
123
123
|
if len(speed)!= 3:
|
|
@@ -130,9 +130,7 @@ class Motor(object):
|
|
|
130
130
|
def move_xy(self, steps=(0,0), speed=(1000,1000), is_blocking=False, is_absolute=False, is_enabled=True, timeout=gTIMEOUT):
|
|
131
131
|
if self.isCoreXY:
|
|
132
132
|
# have to move only one motor to move in XY direction
|
|
133
|
-
|
|
134
|
-
#self.move_axis_by_name(axis="Y", steps=steps[1], speed=speed[1], is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
135
|
-
return self.move_xyzt(steps=(0,steps[0], steps[1], 0), speed=(0,speed[0],speed[1],0), is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
133
|
+
return self.move_xyzt(steps=(0,steps[0], steps[1], 0), speed=(0,speed[0],speed[1],0), is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
136
134
|
else:
|
|
137
135
|
if len(speed)!= 2:
|
|
138
136
|
speed = (speed,speed)
|
|
@@ -150,7 +148,7 @@ class Motor(object):
|
|
|
150
148
|
r = self.move_stepper(steps=steps, speed=speed, backlash=(self.backlash[0],self.backlash[1],self.backlash[2],self.backlash[3]), is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled, timeout=timeout)
|
|
151
149
|
return r
|
|
152
150
|
|
|
153
|
-
def move_axis_by_name(self, axis="X", steps=100, speed=1000, is_blocking=False, is_absolute=False, is_enabled=True, timeout=gTIMEOUT):
|
|
151
|
+
def move_axis_by_name(self, axis="X", steps=100, speed=1000, acceleration=None, is_blocking=False, is_absolute=False, is_enabled=True, timeout=gTIMEOUT):
|
|
154
152
|
axis = self.xyztTo1230(axis)
|
|
155
153
|
_speed=np.zeros(4)
|
|
156
154
|
_speed[axis] = speed
|
|
@@ -158,7 +156,8 @@ class Motor(object):
|
|
|
158
156
|
_steps[axis] = steps
|
|
159
157
|
_backlash=np.zeros(4)
|
|
160
158
|
_backlash[axis] = self.backlash[axis]
|
|
161
|
-
|
|
159
|
+
_acceleration=acceleration
|
|
160
|
+
r = self.move_stepper(_steps, speed=_speed, acceleration=_acceleration, timeout=timeout, backlash=_backlash, is_blocking=is_blocking, is_absolute=is_absolute, is_enabled=is_enabled)
|
|
162
161
|
return r
|
|
163
162
|
|
|
164
163
|
def move_forever(self, speed=(0,0,0,0), is_stop=False):
|
|
@@ -226,7 +225,7 @@ class Motor(object):
|
|
|
226
225
|
return r
|
|
227
226
|
|
|
228
227
|
|
|
229
|
-
def move_stepper(self, steps=(0,0,0,0), speed=(1000,1000,1000,1000), is_absolute=(False,False,False,False), timeout=
|
|
228
|
+
def move_stepper(self, steps=(0,0,0,0), speed=(1000,1000,1000,1000), is_absolute=(False,False,False,False), timeout=gTIMEOUT, backlash=(0,0,0,0), acceleration=(None, None, None, None), is_blocking=True, is_enabled=True):
|
|
230
229
|
'''
|
|
231
230
|
This tells the motor to run at a given speed for a specific number of steps; Multiple motors can run simultaneously
|
|
232
231
|
|
|
@@ -246,6 +245,10 @@ class Motor(object):
|
|
|
246
245
|
if type(speed)!=list and type(speed)!=tuple and type(speed)!=np.ndarray:
|
|
247
246
|
speed = np.array((speed,speed,speed,speed))
|
|
248
247
|
|
|
248
|
+
# convert single elements to array
|
|
249
|
+
if type(acceleration)!=list and type(acceleration)!=tuple and type(acceleration)!=np.ndarray:
|
|
250
|
+
acceleration = np.array((acceleration,acceleration,acceleration,acceleration))
|
|
251
|
+
|
|
249
252
|
# make sure value is an array
|
|
250
253
|
if type(steps)==tuple:
|
|
251
254
|
steps = np.array(steps)
|
|
@@ -277,30 +280,6 @@ class Motor(object):
|
|
|
277
280
|
steps_3 = 0
|
|
278
281
|
'''
|
|
279
282
|
|
|
280
|
-
'''
|
|
281
|
-
{"task":"/motor_act",
|
|
282
|
-
"motor":{
|
|
283
|
-
"steppers":[
|
|
284
|
-
{
|
|
285
|
-
"stepperid":1,
|
|
286
|
-
"position":-1000,
|
|
287
|
-
"speed":2000,
|
|
288
|
-
"isabs":0,
|
|
289
|
-
"isaccel":0
|
|
290
|
-
}
|
|
291
|
-
]
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
{"task":"/motor_act",
|
|
296
|
-
"motor":
|
|
297
|
-
{
|
|
298
|
-
"steppers": [
|
|
299
|
-
{ "stepperid": 1, "position": -100, "speed": 2000, "isabs": 0, "isaccel":0}
|
|
300
|
-
]
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
'''
|
|
304
283
|
|
|
305
284
|
# only consider those actions that are necessary
|
|
306
285
|
motorPropList = []
|
|
@@ -312,6 +291,8 @@ class Motor(object):
|
|
|
312
291
|
"isabs": isAbsoluteArray[iMotor],
|
|
313
292
|
"isaccel":0,
|
|
314
293
|
"isen": is_enabled}
|
|
294
|
+
if acceleration[iMotor] is not None:
|
|
295
|
+
motorProp["accel"] = int(acceleration[iMotor])
|
|
315
296
|
motorPropList.append(motorProp)
|
|
316
297
|
|
|
317
298
|
path = "/motor_act"
|
|
@@ -333,7 +314,10 @@ class Motor(object):
|
|
|
333
314
|
|
|
334
315
|
# wait until job has been done
|
|
335
316
|
time0=time.time()
|
|
336
|
-
|
|
317
|
+
if np.sum(isAbsoluteArray):
|
|
318
|
+
steppersRunning = isAbsoluteArray
|
|
319
|
+
else:
|
|
320
|
+
steppersRunning = np.abs(np.array(steps))>0
|
|
337
321
|
if not self._parent.is_wifi and is_blocking and self._parent.serial.is_connected:
|
|
338
322
|
while True:
|
|
339
323
|
time.sleep(0.05) # don'T overwhelm the CPU
|
|
@@ -424,13 +408,24 @@ class Motor(object):
|
|
|
424
408
|
r = self.set_motor(stepperid = axis, position = currentPosition)
|
|
425
409
|
return r
|
|
426
410
|
|
|
427
|
-
def set_motor_acceleration(self, axis=0, acceleration=
|
|
411
|
+
def set_motor_acceleration(self, axis=0, acceleration=40000):
|
|
428
412
|
if type(axis)==str:
|
|
429
413
|
axis = self.xyztTo1230(axis)
|
|
430
414
|
|
|
431
|
-
|
|
415
|
+
path = "/motor_act"
|
|
416
|
+
payload = {
|
|
417
|
+
"task": path,
|
|
418
|
+
"motor":
|
|
419
|
+
{
|
|
420
|
+
"steppers": [
|
|
421
|
+
{ "stepperid":axis, "isaccel":1, "accel":acceleration}
|
|
422
|
+
]
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
r = self._parent.post_json(path, payload)
|
|
432
426
|
return r
|
|
433
427
|
|
|
428
|
+
|
|
434
429
|
def set_motor_enable(self, is_enable=1):
|
|
435
430
|
self.set_motor_enable(enable=is_enable)
|
|
436
431
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|