Skip to content

Commit 889e0fe

Browse files
author
andy
committed
add compensation
1 parent aa29e0e commit 889e0fe

File tree

7 files changed

+74
-48
lines changed

7 files changed

+74
-48
lines changed

drivers/serial_driver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def read_buffer(self):
109109
self.com.flushOutput()
110110
except:
111111
pass
112-
time.sleep(3)
112+
time.sleep(0.1)
113113
# length = self.com.inWaiting()
114114
length = ReceiveBuffer if self.receive_buffer is None else self.receive_buffer
115115
data = self.com.read(length)
@@ -133,7 +133,7 @@ def read_buffer2(self, read_length, hex_flag=None):
133133

134134
if __name__ == '__main__':
135135
s = SerialDriver()
136-
s.init(115200)
136+
s.init(9600)
137137
for i in range(100):
138-
data = s.read_buffer2(28, hex_flag=True)
138+
data = s.read_buffer()
139139
print(data)

ot3_testing/test_config/pipette_leveling_config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ class CalibrateMethod(enum.Enum):
77
Dichotomy = "dichotomy"
88

99

10-
SlotLocationCH96 = {"C1-Y": {"Point": Point(223, 203, 318), "compensation": {"left_rear": 0, "left_front": 0}},
10+
SlotLocationCH96 = {"C1-Y": {"Point": Point(223, 203, 318), "compensation": {"left_rear": 0.038, "left_front": 0}},
1111
"C3-Y": {"Point": Point(207, 203, 318), "compensation": {"right_rear": 0, "right_front": 0}},
1212
"A2-Y": {"Point": Point(387, 421, 318), "compensation": {"left_rear": 0, "left_front": 0}},
1313
"C1-X": {"Point": Point(50, 91, 300), "compensation": {"left": 0, "right": 0}},
1414
"C3-X": {"Point": Point(382, 91, 300), "compensation": {"left": 0, "right": 0}},
1515
"A2-X": {"Point": Point(213, 305, 300), "compensation": {"left": 0, "right": 0}},
1616
"D1-Z": {"Point": Point(51, 99, 318),
17-
"compensation": {"rear_left": 0.09, "rear_right": 0.01, "front_left": 0.11,
17+
"compensation": {"rear_left": 0.001, "rear_right": -0.005, "front_left": 0.018,
1818
"front_right": 0}},
1919
# "B2-Z": Point(213, 324, 317),
2020
"D3-Z": {"Point": Point(377, 99, 318),
21-
"compensation": {"rear_left": 0.09, "rear_right": 0.01, "front_left": 0.11,
21+
"compensation": {"rear_left": 0.003, "rear_right": -0.021, "front_left": -0.037,
2222
"front_right": 0}},
2323
"C2-Z": {"Point": Point(214, 210, 318),
24-
"compensation": {"rear_left": 0.09, "rear_right": 0.01, "front_left": 0.11,
24+
"compensation": {"rear_left": 0.025, "rear_right": -0.007, "front_left": 0.046,
2525
"front_right": 0}},
2626
"A2-Z": {"Point": Point(218, 424, 390.5),
27-
"compensation": {"rear_left": 0.09, "rear_right": 0.01, "front_left": 0.11,
27+
"compensation": {"rear_left": 0, "rear_right": 0, "front_left": 0,
2828
"front_right": 0}},
2929
"UninstallPos": {"Point": Point(223, 203, 500)}
3030
}

ot3_testing/test_config/zstage_leveling_config.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,39 @@ class CalibrateMethod(enum.Enum):
1010
ZStagePoint = {
1111

1212
Mount.LEFT: {
13-
"Z-A1": {"point": Point(214, 210, 418), "compensation": {"rear": 0, "front": 0},
13+
14+
"Z-C2": {"point": Point(195, 197, 357), "compensation": {"rear": 0, "front": 0},
15+
"channel_definition": ["below_rear", "below_front"]},
16+
17+
},
18+
Mount.RIGHT: {
19+
"Z-A1": {"point": Point(5, 410, 357), "compensation": {"rear": 0, "front": 0},
1420
"channel_definition": ["below_rear", "below_front"]},
15-
"Z-A2": {"point": Point(214, 210, 418), "compensation": {"rear": 0, "front": 0},
21+
"Z-A2": {"point": Point(175, 410, 357), "compensation": {"rear": 0, "front": 0},
1622
"channel_definition": ["below_rear", "below_front"]},
17-
"Z-A3": {"point": Point(214, 210, 418), "compensation": {"rear": 0, "front": 0},
23+
"Z-A3": {"point": Point(335, 410, 357), "compensation": {"rear": 0, "front": 0},
1824
"channel_definition": ["below_rear", "below_front"]},
19-
"Z-B1": {"point": Point(214, 210, 418), "compensation": {"rear": 0, "front": 0},
25+
"Z-B1": {"point": Point(5, 305, 357), "compensation": {"rear": 0, "front": 0},
2026
"channel_definition": ["below_rear", "below_front"]},
21-
"Z-B2": {"point": Point(214, 210, 418), "compensation": {"rear": 0, "front": 0},
27+
"Z-B2": {"point": Point(175, 305, 357), "compensation": {"rear": 0, "front": 0},
2228
"channel_definition": ["below_rear", "below_front"]},
23-
"Z-B3": {"point": Point(214, 210, 418), "compensation": {"rear": 0, "front": 0},
29+
"Z-B3": {"point": Point(335, 305, 357), "compensation": {"rear": 0, "front": 0},
2430
"channel_definition": ["below_rear", "below_front"]},
25-
"Z-C1": {"point": Point(214, 210, 418), "compensation": {"rear": 0, "front": 0},
31+
"Z-C1": {"point": Point(5, 197, 357), "compensation": {"rear": 0, "front": 0},
2632
"channel_definition": ["below_rear", "below_front"]},
27-
"Z-C2": {"point": Point(214, 210, 418), "compensation": {"rear": 0, "front": 0},
33+
"Z-C2": {"point": Point(175, 197, 357), "compensation": {"rear": 0, "front": 0},
2834
"channel_definition": ["below_rear", "below_front"]},
29-
"Z-C3": {"point": Point(214, 210, 418), "compensation": {"rear": 0, "front": 0},
35+
36+
"Z-C3": {"point": Point(335, 197, 357), "compensation": {"rear": 0, "front": 0},
3037
"channel_definition": ["below_rear", "below_front"]},
31-
"Z-D1": {"point": Point(214, 210, 418), "compensation": {"rear": 0, "front": 0},
38+
"Z-D1": {"point": Point(5, 92, 357), "compensation": {"rear": 0, "front": 0},
3239
"channel_definition": ["below_rear", "below_front"]},
33-
"Z-D2": {"point": Point(214, 210, 418), "compensation": {"rear": 0, "front": 0},
40+
"Z-D2": {"point": Point(175, 92, 357), "compensation": {"rear": 0, "front": 0},
3441
"channel_definition": ["below_rear", "below_front"]},
35-
"Z-D3": {"point": Point(214, 210, 418), "compensation": {"rear": 0, "front": 0},
42+
"Z-D3": {"point": Point(335, 92, 357), "compensation": {"rear": 0, "front": 0},
3643
"channel_definition": ["below_rear", "below_front"]},
37-
},
38-
Mount.RIGHT: {
39-
"Z-C2": {"point": Point(177, 197, 357), "compensation": {"rear": 0, "front": 0},
40-
"channel_definition": ["below_rear", "below_front"]}
44+
45+
4146
}
4247
}
4348

Binary file not shown.

ot3_testing/tests/base_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async def read_definition_distance(self, definition: List, channel_definition, l
101101

102102
else:
103103
for item in definition:
104-
code_value = code_value_list[channel_definition[item]["channel"]]
104+
code_value = code_value_list[_channel_definition[item]["channel"]]
105105
distance_value = await self.read_distance_mm_from_code_value(code_value)
106106
result.update({item: distance_value})
107107

ot3_testing/tests/pipette_leveling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ async def run_96ch_test(self, flex_name: str, project_path=None):
420420

421421
# pipette_leveling = PipetteLeveling(SlotLocationCH96, ChannelDefinitionCH96, )
422422
# pipette_leveling.test_name = '96ch'
423-
# asyncio.run(pipette_leveling.run_96ch_test("0518003"))
423+
# asyncio.run(pipette_leveling.run_96ch_test("0527001"))
424424

425425
pipette_leveling = PipetteLeveling(SlotLocationCH8, ChannelDefinitionCH8, )
426426
pipette_leveling.test_name = '8ch'
427-
asyncio.run(pipette_leveling.run_8ch_test("0518003"))
427+
asyncio.run(pipette_leveling.run_8ch_test("0527001"))

ot3_testing/tests/zstage_leveling.py

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import threading
2+
13
from ot3_testing.tests.base_init import TestBase
24
from ot3_testing.ot_type import Mount, Point
35
from devices.amsamotion_sensor import LaserSensor
@@ -16,6 +18,7 @@ def __init__(self, slot_location, robot_ip=None):
1618
self.laser_sensor = None
1719
self.slot_location: ZStagePoint = slot_location
1820
self.approaching = False
21+
self.judge_complete = False
1922

2023
def init_laser_sensor(self, send=False):
2124
"""
@@ -129,15 +132,39 @@ async def run_test_slot(self, point: Point, slot_name: str, read_definition: Lis
129132
print(f"Test - {slot_name}")
130133
await self.move_to_test_point(point)
131134
if with_cal:
132-
await self.calibrate_to_zero(slot_name, 0.1, read_definition, ZStageChannel[self.mount],
135+
await self.calibrate_to_zero(slot_name, 0.1, read_definition, ZStageChannel,
133136
method=CalibrateMethod.Approach)
134137

135-
ret_dict = await self.read_definition_distance(read_definition)
138+
ret_dict = await self.read_definition_distance(read_definition, ZStageChannel, self.laser_sensor, self.mount)
136139
for key, value in ret_dict.items():
137140
print(f"{slot_name}-{key}: {value}")
138141

139142
return {slot_name: ret_dict}
140143

144+
async def th_reading_c2(self):
145+
while True:
146+
ret_dict = await self.read_definition_distance(ZStagePoint[Mount.RIGHT]['Z-C2']["channel_definition"],
147+
ZStageChannel, self.laser_sensor, self.mount)
148+
_ret_list = list(ret_dict.values())
149+
_difference = round(abs(max(_ret_list) - min(_ret_list)), 3)
150+
difference = int(-_difference * 1500 + 1500)
151+
if difference < 200:
152+
difference = 200
153+
if difference > 1500:
154+
difference = 1500
155+
fre = 100 if _difference > 0.03 else 1000
156+
print(_difference, difference)
157+
play_alarm_3(difference, fre)
158+
if self.judge_complete:
159+
break
160+
161+
def run_th_reading_c2(self):
162+
loop = asyncio.new_event_loop()
163+
asyncio.set_event_loop(loop)
164+
future = asyncio.run_coroutine_threadsafe(self.th_reading_c2(), loop)
165+
future.running()
166+
# return future.result()
167+
141168
async def adjust_leveling(self, slot_name: str, mount: Mount):
142169
"""
143170
移动到指定slot, 调平
@@ -148,24 +175,12 @@ async def adjust_leveling(self, slot_name: str, mount: Mount):
148175
await self.move_to_test_point(_point)
149176
await self.calibrate_to_zero(slot_name, 0.1, _definition, ZStageChannel, method=CalibrateMethod.Approach)
150177

151-
while True:
152-
play_alarm_3(500, 500)
153-
154-
# async def thread_play_beep():
155-
# while True:
156-
# result = await self.read_definition_distance(_definition, ZStageChannel, self.laser_sensor)
157-
# _rear = result['below_rear']
158-
# _front = result['below_front']
159-
# print(f"Rear: {_rear}")
160-
# print(f"_front: {_front}")
161-
# difference = _rear - _front
162-
# if abs(difference) > 0.03:
163-
# play_alarm_3(1000, 500)
164-
# else:
165-
# play_alarm_3(500, 500)
166-
#
167-
# while True:
168-
# result: dict = await self.read_definition_distance(_definition, ZStageChannel, self.laser_sensor, self.mount)
178+
th = threading.Thread(target=self.run_th_reading_c2)
179+
th.start()
180+
th.join()
181+
182+
input("Judging complete ? (完成校准回车)")
183+
self.judge_complete = True
169184

170185
async def run_z_stage_test(self):
171186
"""
@@ -183,6 +198,9 @@ async def run_z_stage_test(self):
183198
# adjust
184199
await self.adjust_leveling('Z-C2', Mount.RIGHT)
185200

201+
await self.api.home()
202+
203+
input("run test")
186204
# run test
187205
for mount in [Mount.RIGHT, Mount.LEFT]:
188206
self.mount = mount
@@ -191,7 +209,10 @@ async def run_z_stage_test(self):
191209
_point = p_value["point"]
192210
_compensation = p_value["compensation"]
193211
_channel_definition = p_value["channel_definition"]
194-
await self.run_test_slot(_point, p_key, _channel_definition)
212+
result = await self.run_test_slot(_point, p_key, _channel_definition)
213+
test_result.update(result)
214+
await self.api.home()
215+
print(test_result)
195216
# save
196217

197218

0 commit comments

Comments
 (0)