Skip to content

Commit 61542e9

Browse files
author
andy
committed
z-stage leveling complete
1 parent 8e5e272 commit 61542e9

File tree

6 files changed

+65
-18
lines changed

6 files changed

+65
-18
lines changed

__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import subprocess
33

4-
VERSION = '1.1.4'
4+
VERSION = '1.1.5'
55

66

77
def get_version():

dist/Productions.exe

4.77 KB
Binary file not shown.

ot3_testing/test_config/zstage_leveling_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class CalibrateMethod(enum.Enum):
1111

1212
Mount.LEFT: {
1313

14-
"Z-C2": {"point": Point(195, 197, 357), "compensation": {"rear": 0, "front": 0},
14+
"Z-C2": {"point": Point(215, 197, 357), "compensation": {"rear": 0, "front": 0},
1515
"channel_definition": ["below_rear", "below_front"]},
1616

1717
},

ot3_testing/tests/zstage_leveling.py

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
from ot3_testing.test_config.zstage_leveling_config import ZStagePoint, CalibrateMethod, ZStageChannel
77
from typing import List
88
from drivers.play_sound import play_alarm_3
9-
9+
from utils import Utils
10+
import os
11+
import asyncio
1012
RequestReadyFlag = False
13+
ApplyCompensationFlag = True
1114

1215

1316
class ZStageLeveling(TestBase):
@@ -178,11 +181,11 @@ async def adjust_leveling(self, slot_name: str, mount: Mount):
178181
input("Judging complete ? (完成校准回车)")
179182
self.judge_complete = True
180183

181-
async def run_z_stage_test(self):
184+
async def run_z_stage_test(self, project_path=None):
182185
"""
183186
main loop
184187
"""
185-
test_result = {}
188+
self.judge_complete = False
186189
if self.robot_ip is None:
187190
addr = self.get_address().strip()
188191
else:
@@ -193,13 +196,16 @@ async def run_z_stage_test(self):
193196

194197
# adjust
195198
await self.adjust_leveling('Z-C2', Mount.RIGHT)
196-
197-
await self.api.home()
198-
199199
input("Run Test (开始测试)?")
200200
# run test
201+
await self.api.home()
202+
203+
csv_title = []
204+
csv_list = []
205+
201206
for mount in [Mount.RIGHT, Mount.LEFT]:
202207
self.mount = mount
208+
test_result = {}
203209
print(f"Start {self.mount.value} side...")
204210
for p_key, p_value in ZStagePoint[self.mount].items():
205211
_point = p_value["point"]
@@ -208,12 +214,47 @@ async def run_z_stage_test(self):
208214
result = await self.run_test_slot(_point, p_key, _channel_definition)
209215
test_result.update(result)
210216
await self.api.home()
211-
print(test_result)
212-
# save
217+
print(test_result)
218+
# save
219+
for key, value in test_result.items():
220+
result = []
221+
distance_list = list(value.values())
222+
difference = round(abs(distance_list[0] - distance_list[1]), 3)
223+
compensation = ZStagePoint[self.mount][key]["compensation"]
224+
if ApplyCompensationFlag:
225+
compensation_idx = 0
226+
for compensation_key, compensation_value in compensation.items():
227+
print(
228+
f"apply offset {compensation_key} -> {compensation_value} to {distance_list[compensation_idx]}")
229+
result.append(compensation_value + distance_list[compensation_idx])
230+
compensation_idx += 1
231+
difference = round(abs(result[0] - result[1]), 3)
232+
print(f"{key} --> {value} (mm) --> difference: {difference}(mm)")
233+
for item_key, item_value in value.items():
234+
csv_title.append(self.mount.name + " " + key + " " + item_key)
235+
csv_list.append(item_value)
236+
csv_title.append(key + "-Result")
237+
csv_list.append(difference)
213238

239+
if project_path is not None:
240+
file_path = os.path.join(project_path, 'testing_data', 'z_stage_leveling.csv')
241+
else:
242+
file_path = '../../testing_data/z_stage_leveling.csv'
243+
self.save_csv(file_path, csv_title, csv_list)
244+
self.laser_sensor.close()
214245

215-
if __name__ == '__main__':
216-
import asyncio
246+
def save_csv(self, file_path, title, content):
247+
"""
248+
save csv
249+
"""
250+
is_exist = Utils.is_file_exist(file_path)
251+
if is_exist:
252+
pass
253+
else:
254+
Utils.write_to_csv(file_path, title)
255+
Utils.write_to_csv(file_path, content)
217256

218-
obj = ZStageLeveling(ZStagePoint, robot_ip="192.168.6.51")
257+
258+
if __name__ == '__main__':
259+
obj = ZStageLeveling(ZStagePoint, robot_ip="192.168.6.33")
219260
asyncio.run(obj.run_z_stage_test())

production_scripts.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import os, sys
2-
1+
import os
2+
import sys
33
from ot3_testing.tests.pipette_leveling import PipetteLeveling
4+
from ot3_testing.tests.zstage_leveling import ZStageLeveling
45
from ot3_testing.test_config.pipette_leveling_config import SlotLocationCH96, ChannelDefinitionCH96, \
56
SlotLocationCH8, ChannelDefinitionCH8
7+
from ot3_testing.test_config.zstage_leveling_config import ZStagePoint
68
import asyncio
79
from tools.inquirer import prompt_flex_name, prompt_test_name, prompt_exit
810
from tools import heat_96ch
@@ -30,6 +32,10 @@
3032
elif "leveling-96ch" in test_name:
3133
pipette_leveling = PipetteLeveling(SlotLocationCH96, ChannelDefinitionCH96, )
3234
asyncio.run(pipette_leveling.run_96ch_test(flex_name, project_path=project_path))
35+
elif "leveling-z-stage" in test_name:
36+
z_leveling = ZStageLeveling(ZStagePoint)
37+
asyncio.run(z_leveling.run_z_stage_test(project_path=project_path))
38+
3339
elif "leveling-8ch" in test_name:
3440
# run 8
3541
pipette_leveling = PipetteLeveling(SlotLocationCH8, ChannelDefinitionCH8)

tools/inquirer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from PyInquirer import prompt
22

3-
test_choices = ['leveling-8ch', 'leveling-96ch', 'leveling-gantry', 'heat-96ch','grav-openweb']
3+
test_choices = ['leveling-8ch', 'leveling-96ch', 'leveling-gantry', 'leveling-z-stage', 'heat-96ch', 'grav-openweb']
44

55
question_flex = {
66
'type': 'input',
@@ -22,7 +22,6 @@
2222

2323
}
2424

25-
2625
question_ip = {
2726
'type': 'input',
2827
'name': 'ip',
@@ -60,6 +59,7 @@ def prompt_raspNo():
6059
ret = prompt(question_gravname)
6160
return ret['raspNo'].strip()
6261

62+
6363
def prompt_ip():
6464
ret = prompt(question_ip)
6565
return ret['ip'].strip()
@@ -79,7 +79,7 @@ def prompt_exit():
7979
ret = prompt(question_exit)
8080
return ret['exit'].strip()
8181

82+
8283
def prompt_openweb():
8384
ret = prompt(question_openweb)
8485
return ret['openweb'].strip()
85-

0 commit comments

Comments
 (0)