ephys-link 2.0.0b6__py3-none-any.whl → 2.0.0b9__py3-none-any.whl
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.
- ephys_link/__about__.py +1 -1
- ephys_link/__main__.py +51 -43
- ephys_link/back_end/platform_handler.py +315 -308
- ephys_link/back_end/server.py +274 -202
- ephys_link/bindings/{fake_bindings.py → fake_binding.py} +84 -59
- ephys_link/bindings/{mpm_bindings.py → mpm_binding.py} +315 -278
- ephys_link/bindings/{ump_4_bindings.py → ump_4_binding.py} +157 -132
- ephys_link/front_end/cli.py +104 -98
- ephys_link/front_end/gui.py +204 -215
- ephys_link/{util/base_bindings.py → utils/base_binding.py} +176 -148
- ephys_link/{util → utils}/console.py +127 -130
- ephys_link/utils/constants.py +23 -0
- ephys_link/utils/converters.py +86 -0
- ephys_link/utils/startup.py +65 -0
- ephys_link-2.0.0b9.dist-info/METADATA +91 -0
- ephys_link-2.0.0b9.dist-info/RECORD +25 -0
- {ephys_link-2.0.0b6.dist-info → ephys_link-2.0.0b9.dist-info}/WHEEL +1 -1
- {ephys_link-2.0.0b6.dist-info → ephys_link-2.0.0b9.dist-info}/licenses/LICENSE +674 -674
- ephys_link/bindings/ump_3_bindings.py +0 -138
- ephys_link/resources/CP210xManufacturing.dll +0 -0
- ephys_link/resources/NstMotorCtrl.dll +0 -0
- ephys_link/resources/SiUSBXp.dll +0 -0
- ephys_link/util/common.py +0 -120
- ephys_link-2.0.0b6.dist-info/METADATA +0 -166
- ephys_link-2.0.0b6.dist-info/RECORD +0 -27
- /ephys_link/{util → utils}/__init__.py +0 -0
- {ephys_link-2.0.0b6.dist-info → ephys_link-2.0.0b9.dist-info}/entry_points.txt +0 -0
|
@@ -1,278 +1,315 @@
|
|
|
1
|
-
"""Bindings for New Scale Pathfinder MPM HTTP server platform.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
from
|
|
11
|
-
from
|
|
12
|
-
|
|
13
|
-
from
|
|
14
|
-
from
|
|
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
|
-
self.
|
|
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
|
-
await self.
|
|
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
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
#
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
1
|
+
"""Bindings for New Scale Pathfinder MPM HTTP server platform.
|
|
2
|
+
|
|
3
|
+
Usage: Instantiate MPMBindings to interact with the New Scale Pathfinder MPM HTTP server platform.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from asyncio import get_running_loop, sleep
|
|
7
|
+
from json import dumps
|
|
8
|
+
from typing import Any, final, override
|
|
9
|
+
|
|
10
|
+
from requests import JSONDecodeError, get, put
|
|
11
|
+
from vbl_aquarium.models.unity import Vector3, Vector4
|
|
12
|
+
|
|
13
|
+
from ephys_link.utils.base_binding import BaseBinding
|
|
14
|
+
from ephys_link.utils.converters import scalar_mm_to_um, vector4_to_array
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@final
|
|
18
|
+
class MPMBinding(BaseBinding):
|
|
19
|
+
"""Bindings for New Scale Pathfinder MPM HTTP server platform."""
|
|
20
|
+
|
|
21
|
+
# Valid New Scale manipulator IDs
|
|
22
|
+
VALID_MANIPULATOR_IDS = (
|
|
23
|
+
"A",
|
|
24
|
+
"B",
|
|
25
|
+
"C",
|
|
26
|
+
"D",
|
|
27
|
+
"E",
|
|
28
|
+
"F",
|
|
29
|
+
"G",
|
|
30
|
+
"H",
|
|
31
|
+
"I",
|
|
32
|
+
"J",
|
|
33
|
+
"K",
|
|
34
|
+
"L",
|
|
35
|
+
"M",
|
|
36
|
+
"N",
|
|
37
|
+
"O",
|
|
38
|
+
"P",
|
|
39
|
+
"Q",
|
|
40
|
+
"R",
|
|
41
|
+
"S",
|
|
42
|
+
"T",
|
|
43
|
+
"U",
|
|
44
|
+
"V",
|
|
45
|
+
"W",
|
|
46
|
+
"X",
|
|
47
|
+
"Y",
|
|
48
|
+
"Z",
|
|
49
|
+
"AA",
|
|
50
|
+
"AB",
|
|
51
|
+
"AC",
|
|
52
|
+
"AD",
|
|
53
|
+
"AE",
|
|
54
|
+
"AF",
|
|
55
|
+
"AG",
|
|
56
|
+
"AH",
|
|
57
|
+
"AI",
|
|
58
|
+
"AJ",
|
|
59
|
+
"AK",
|
|
60
|
+
"AL",
|
|
61
|
+
"AM",
|
|
62
|
+
"AN",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# Server cache lifetime (60 FPS).
|
|
66
|
+
CACHE_LIFETIME = 1 / 60
|
|
67
|
+
|
|
68
|
+
# Movement polling preferences.
|
|
69
|
+
UNCHANGED_COUNTER_LIMIT = 10
|
|
70
|
+
POLL_INTERVAL = 0.1
|
|
71
|
+
|
|
72
|
+
# Speed preferences (mm/s to use coarse mode).
|
|
73
|
+
COARSE_SPEED_THRESHOLD = 0.1
|
|
74
|
+
INSERTION_SPEED_LIMIT = 9_000
|
|
75
|
+
|
|
76
|
+
def __init__(self, port: int = 8080) -> None:
|
|
77
|
+
"""Initialize connection to MPM HTTP server.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
port: Port number for MPM HTTP server.
|
|
81
|
+
"""
|
|
82
|
+
self._url = f"http://localhost:{port}"
|
|
83
|
+
self._movement_stopped = False
|
|
84
|
+
|
|
85
|
+
# Data cache.
|
|
86
|
+
self.cache: dict[str, Any] = {} # pyright: ignore [reportExplicitAny]
|
|
87
|
+
self.cache_time = 0
|
|
88
|
+
|
|
89
|
+
@staticmethod
|
|
90
|
+
@override
|
|
91
|
+
def get_display_name() -> str:
|
|
92
|
+
return "Pathfinder MPM Control v2.8.8+"
|
|
93
|
+
|
|
94
|
+
@staticmethod
|
|
95
|
+
@override
|
|
96
|
+
def get_cli_name() -> str:
|
|
97
|
+
return "pathfinder-mpm"
|
|
98
|
+
|
|
99
|
+
@override
|
|
100
|
+
async def get_manipulators(self) -> list[str]:
|
|
101
|
+
return [manipulator["Id"] for manipulator in (await self._query_data())["ProbeArray"]] # pyright: ignore [reportAny]
|
|
102
|
+
|
|
103
|
+
@override
|
|
104
|
+
async def get_axes_count(self) -> int:
|
|
105
|
+
return 3
|
|
106
|
+
|
|
107
|
+
@override
|
|
108
|
+
def get_dimensions(self) -> Vector4:
|
|
109
|
+
return Vector4(x=15, y=15, z=15, w=15)
|
|
110
|
+
|
|
111
|
+
@override
|
|
112
|
+
async def get_position(self, manipulator_id: str) -> Vector4:
|
|
113
|
+
manipulator_data: dict[str, float] = await self._manipulator_data(manipulator_id)
|
|
114
|
+
stage_z: float = manipulator_data["Stage_Z"]
|
|
115
|
+
|
|
116
|
+
await sleep(self.POLL_INTERVAL) # Wait for the stage to stabilize.
|
|
117
|
+
|
|
118
|
+
return Vector4(
|
|
119
|
+
x=manipulator_data["Stage_X"],
|
|
120
|
+
y=manipulator_data["Stage_Y"],
|
|
121
|
+
z=stage_z,
|
|
122
|
+
w=stage_z,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
@override
|
|
126
|
+
async def get_angles(self, manipulator_id: str) -> Vector3:
|
|
127
|
+
manipulator_data: dict[str, float] = await self._manipulator_data(manipulator_id)
|
|
128
|
+
|
|
129
|
+
# Apply PosteriorAngle to Polar to get the correct angle.
|
|
130
|
+
adjusted_polar: int = manipulator_data["Polar"] - (await self._query_data())["PosteriorAngle"]
|
|
131
|
+
|
|
132
|
+
return Vector3(
|
|
133
|
+
x=adjusted_polar if adjusted_polar > 0 else 360 + adjusted_polar,
|
|
134
|
+
y=manipulator_data["Pitch"],
|
|
135
|
+
z=manipulator_data["ShankOrientation"],
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
@override
|
|
139
|
+
async def get_shank_count(self, manipulator_id: str) -> int:
|
|
140
|
+
return int((await self._manipulator_data(manipulator_id))["ShankCount"]) # pyright: ignore [reportAny]
|
|
141
|
+
|
|
142
|
+
@override
|
|
143
|
+
def get_movement_tolerance(self) -> float:
|
|
144
|
+
return 0.01
|
|
145
|
+
|
|
146
|
+
@override
|
|
147
|
+
async def set_position(self, manipulator_id: str, position: Vector4, speed: float) -> Vector4:
|
|
148
|
+
# Keep track of the previous position to check if the manipulator stopped advancing.
|
|
149
|
+
current_position = await self.get_position(manipulator_id)
|
|
150
|
+
previous_position = current_position
|
|
151
|
+
unchanged_counter = 0
|
|
152
|
+
|
|
153
|
+
# Set step mode based on speed.
|
|
154
|
+
await self._put_request(
|
|
155
|
+
{
|
|
156
|
+
"PutId": "ProbeStepMode",
|
|
157
|
+
"Probe": self.VALID_MANIPULATOR_IDS.index(manipulator_id),
|
|
158
|
+
"StepMode": 0 if speed > self.COARSE_SPEED_THRESHOLD else 1,
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
# Send move request.
|
|
163
|
+
await self._put_request(
|
|
164
|
+
{
|
|
165
|
+
"PutId": "ProbeMotion",
|
|
166
|
+
"Probe": self.VALID_MANIPULATOR_IDS.index(manipulator_id),
|
|
167
|
+
"Absolute": 1,
|
|
168
|
+
"Stereotactic": 0,
|
|
169
|
+
"AxisMask": 7,
|
|
170
|
+
"X": position.x,
|
|
171
|
+
"Y": position.y,
|
|
172
|
+
"Z": position.z,
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
# Wait for the manipulator to reach the target position or be stopped or stuck.
|
|
177
|
+
while (
|
|
178
|
+
not self._movement_stopped
|
|
179
|
+
and not self._is_vector_close(current_position, position)
|
|
180
|
+
and unchanged_counter < self.UNCHANGED_COUNTER_LIMIT
|
|
181
|
+
):
|
|
182
|
+
# Wait for a short time before checking again.
|
|
183
|
+
await sleep(self.POLL_INTERVAL)
|
|
184
|
+
|
|
185
|
+
# Update current position.
|
|
186
|
+
current_position = await self.get_position(manipulator_id)
|
|
187
|
+
|
|
188
|
+
# Check if manipulator is not moving.
|
|
189
|
+
if self._is_vector_close(previous_position, current_position):
|
|
190
|
+
# Position did not change.
|
|
191
|
+
unchanged_counter += 1
|
|
192
|
+
else:
|
|
193
|
+
# Position changed.
|
|
194
|
+
unchanged_counter = 0
|
|
195
|
+
previous_position = current_position
|
|
196
|
+
|
|
197
|
+
# Reset movement stopped flag.
|
|
198
|
+
self._movement_stopped = False
|
|
199
|
+
|
|
200
|
+
# Return the final position.
|
|
201
|
+
return await self.get_position(manipulator_id)
|
|
202
|
+
|
|
203
|
+
@override
|
|
204
|
+
async def set_depth(self, manipulator_id: str, depth: float, speed: float) -> float:
|
|
205
|
+
# Keep track of the previous depth to check if the manipulator stopped advancing unexpectedly.
|
|
206
|
+
current_depth = (await self.get_position(manipulator_id)).w
|
|
207
|
+
previous_depth = current_depth
|
|
208
|
+
unchanged_counter = 0
|
|
209
|
+
|
|
210
|
+
# Send move request.
|
|
211
|
+
# Convert mm/s to um/min and cap speed at the limit.
|
|
212
|
+
await self._put_request(
|
|
213
|
+
{
|
|
214
|
+
"PutId": "ProbeInsertion",
|
|
215
|
+
"Probe": self.VALID_MANIPULATOR_IDS.index(manipulator_id),
|
|
216
|
+
"Distance": scalar_mm_to_um(current_depth - depth),
|
|
217
|
+
"Rate": min(scalar_mm_to_um(speed) * 60, self.INSERTION_SPEED_LIMIT),
|
|
218
|
+
}
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
# Wait for the manipulator to reach the target depth or be stopped or get stuck.
|
|
222
|
+
while not self._movement_stopped and not abs(current_depth - depth) <= self.get_movement_tolerance():
|
|
223
|
+
# Wait for a short time before checking again.
|
|
224
|
+
await sleep(self.POLL_INTERVAL)
|
|
225
|
+
|
|
226
|
+
# Get the current depth.
|
|
227
|
+
current_depth = (await self.get_position(manipulator_id)).w
|
|
228
|
+
|
|
229
|
+
# Check if manipulator is not moving.
|
|
230
|
+
if abs(previous_depth - current_depth) <= self.get_movement_tolerance():
|
|
231
|
+
# Depth did not change.
|
|
232
|
+
unchanged_counter += 1
|
|
233
|
+
else:
|
|
234
|
+
# Depth changed.
|
|
235
|
+
unchanged_counter = 0
|
|
236
|
+
previous_depth = current_depth
|
|
237
|
+
|
|
238
|
+
# Reset movement stopped flag.
|
|
239
|
+
self._movement_stopped = False
|
|
240
|
+
|
|
241
|
+
# Return the final depth.
|
|
242
|
+
return float((await self.get_position(manipulator_id)).w)
|
|
243
|
+
|
|
244
|
+
@override
|
|
245
|
+
async def stop(self, manipulator_id: str) -> None:
|
|
246
|
+
request: dict[str, str | int | float] = {
|
|
247
|
+
"PutId": "ProbeStop",
|
|
248
|
+
"Probe": self.VALID_MANIPULATOR_IDS.index(manipulator_id),
|
|
249
|
+
}
|
|
250
|
+
await self._put_request(request)
|
|
251
|
+
self._movement_stopped = True
|
|
252
|
+
|
|
253
|
+
@override
|
|
254
|
+
def platform_space_to_unified_space(self, platform_space: Vector4) -> Vector4:
|
|
255
|
+
# unified <- platform
|
|
256
|
+
# +x <- -x
|
|
257
|
+
# +y <- +z
|
|
258
|
+
# +z <- +y
|
|
259
|
+
# +w <- -w
|
|
260
|
+
|
|
261
|
+
return Vector4(
|
|
262
|
+
x=self.get_dimensions().x - platform_space.x,
|
|
263
|
+
y=platform_space.z,
|
|
264
|
+
z=platform_space.y,
|
|
265
|
+
w=self.get_dimensions().w - platform_space.w,
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
@override
|
|
269
|
+
def unified_space_to_platform_space(self, unified_space: Vector4) -> Vector4:
|
|
270
|
+
# platform <- unified
|
|
271
|
+
# +x <- -x
|
|
272
|
+
# +y <- +z
|
|
273
|
+
# +z <- +y
|
|
274
|
+
# +w <- -w
|
|
275
|
+
|
|
276
|
+
return Vector4(
|
|
277
|
+
x=self.get_dimensions().x - unified_space.x,
|
|
278
|
+
y=unified_space.z,
|
|
279
|
+
z=unified_space.y,
|
|
280
|
+
w=self.get_dimensions().w - unified_space.w,
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
# Helper functions.
|
|
284
|
+
async def _query_data(self) -> dict[str, Any]: # pyright: ignore [reportExplicitAny]
|
|
285
|
+
try:
|
|
286
|
+
# Update cache if it's expired.
|
|
287
|
+
if get_running_loop().time() - self.cache_time > self.CACHE_LIFETIME:
|
|
288
|
+
# noinspection PyTypeChecker
|
|
289
|
+
self.cache = (await get_running_loop().run_in_executor(None, get, self._url)).json()
|
|
290
|
+
self.cache_time = get_running_loop().time()
|
|
291
|
+
except ConnectionError as connectionError:
|
|
292
|
+
error_message = f"Unable to connect to MPM HTTP server: {connectionError}"
|
|
293
|
+
raise RuntimeError(error_message) from connectionError
|
|
294
|
+
except JSONDecodeError as jsonDecodeError:
|
|
295
|
+
error_message = f"Unable to decode JSON response from MPM HTTP server: {jsonDecodeError}"
|
|
296
|
+
raise ValueError(error_message) from jsonDecodeError
|
|
297
|
+
else:
|
|
298
|
+
# Return cached data.
|
|
299
|
+
return self.cache
|
|
300
|
+
|
|
301
|
+
async def _manipulator_data(self, manipulator_id: str) -> dict[str, Any]: # pyright: ignore [reportExplicitAny]
|
|
302
|
+
probe_data: list[dict[str, Any]] = (await self._query_data())["ProbeArray"] # pyright: ignore [reportExplicitAny]
|
|
303
|
+
for probe in probe_data:
|
|
304
|
+
if probe["Id"] == manipulator_id:
|
|
305
|
+
return probe
|
|
306
|
+
|
|
307
|
+
# If we get here, that means the manipulator doesn't exist.
|
|
308
|
+
error_message = f"Manipulator {manipulator_id} not found."
|
|
309
|
+
raise ValueError(error_message)
|
|
310
|
+
|
|
311
|
+
async def _put_request(self, request: dict[str, Any]) -> None: # pyright: ignore [reportExplicitAny]
|
|
312
|
+
_ = await get_running_loop().run_in_executor(None, put, self._url, dumps(request))
|
|
313
|
+
|
|
314
|
+
def _is_vector_close(self, target: Vector4, current: Vector4) -> bool:
|
|
315
|
+
return all(abs(axis) <= self.get_movement_tolerance() for axis in vector4_to_array(target - current)[:3])
|