Skip to content

Commit c866a8a

Browse files
committed
Put the lid on when plate is on B15
1 parent ff4353d commit c866a8a

File tree

5 files changed

+79
-33
lines changed

5 files changed

+79
-33
lines changed

cellpainter/cellpainter/moves.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def tags(self) -> list[str]:
213213
out += [tag]
214214
return out
215215

216-
def expand_hotels(self, name: str) -> dict[str, MoveList]:
216+
def expand_hotels(self, name: str, *, expand_base: bool) -> dict[str, MoveList]:
217217
'''
218218
If there is a tag like 19/21 then expand to all heights 1/21, 3/21, .., 21/21
219219
The first occurence of 19 in the name is replaced with 1, 3, .., 21, so
@@ -233,14 +233,22 @@ def expand_hotels(self, name: str) -> dict[str, MoveList]:
233233
else:
234234
raise ValueError(f'Unknown hotel in: {name}')
235235
for tag in set(self.tags()):
236-
if m := re.match(r'(\d+)/(11|21)$', tag):
237-
ref_h = int(m.group(1))
238-
assert str(ref_h) in name
239-
assert ref_h in hotel_locs
240-
for h in hotel_locs:
241-
dz = (h - ref_h) * hotel_dist
242-
name_h = name.replace(str(ref_h), str(h), 1)
243-
out[name_h] = self.adjust_tagged(tag, dname=str(h), dz=dz)
236+
if expand_base:
237+
if tag == 'base 21':
238+
ref_h = 21
239+
for h in [15]:
240+
dz = (h - ref_h) * hotel_dist
241+
name_h = f'{name} [base B{h}]'
242+
out[name_h] = self.adjust_tagged(tag, dname=f'[base B{h}]', dz=dz)
243+
if not expand_base:
244+
if m := re.match(r'(\d+)/(11|21)$', tag):
245+
ref_h = int(m.group(1))
246+
assert str(ref_h) in name
247+
assert ref_h in hotel_locs
248+
for h in hotel_locs:
249+
dz = (h - ref_h) * hotel_dist
250+
name_h = name.replace(str(ref_h), str(h), 1)
251+
out[name_h] = self.adjust_tagged(tag, dname=str(h), dz=dz)
244252
return out
245253

246254
def with_sections(self, include_Section: bool=False) -> list[tuple[str, Move]]:
@@ -467,7 +475,9 @@ def read_and_expand(filename: Path) -> dict[str, MoveList]:
467475
ml = MoveList.read_jsonl(filename)
468476
expanded = ml.expand_sections()
469477
for k, v in list(expanded.items()):
470-
expanded |= v.expand_hotels(k)
478+
expanded |= v.expand_hotels(k, expand_base=False)
479+
for k, v in list(expanded.items()):
480+
expanded |= v.expand_hotels(k, expand_base=True)
471481
return expanded
472482

473483
def read_movelists() -> dict[str, MoveList]:
@@ -589,6 +599,7 @@ def effect(self, world: World) -> dict[str, str | None]:
589599
movelists = read_movelists()
590600

591601
B21 = 'B21'
602+
B15 = 'B15'
592603
effects: dict[str, Effect] = {}
593604

594605
for k, v in movelists.items():
@@ -613,6 +624,10 @@ def effect(self, world: World) -> dict[str, str | None]:
613624
effects[lid_Bi + ' get'] = PutLidOn(source=Bi, target=B21)
614625
effects[lid_Bi + ' put'] = TakeLidOff(source=B21, target=Bi)
615626

627+
lid_Bi = f'lid-B{i} [base B15]'
628+
effects[lid_Bi + ' get'] = PutLidOn(source=Bi, target=B15)
629+
effects[lid_Bi + ' put'] = TakeLidOff(source=B15, target=Bi)
630+
616631
for k in list(effects.keys()):
617632
effects[k + ' transfer'] = effects[k]
618633

cellpainter/cellpainter/protocol.py

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class OptPrio:
4141
wash_to_disp = Min(priority=6, weight=1)
4242
incu_slack = Min(priority=6, weight=1)
4343
without_lid = Min(priority=4, weight=1)
44-
batch_time = Min(priority=3, weight=1)
44+
total_time = Min(priority=3, weight=1)
4545
squeeze_steps = Min(priority=2, weight=1)
4646
inside_incu = Max(priority=1, weight=0)
4747

@@ -62,6 +62,10 @@ def lid_put(self):
6262
def lid_get(self):
6363
return f'lid-{self.lid_loc} get'
6464

65+
@property
66+
def lid_get_base_B15(self):
67+
return f'lid-{self.lid_loc} get [base B15]'
68+
6569
@property
6670
def rt_put(self):
6771
return f'{self.rt_loc} put'
@@ -333,6 +337,21 @@ class ProtocolConfig:
333337
blue_prime: list[str]
334338
use_blue: bool
335339

340+
'''
341+
def any_disp(self):
342+
return any([
343+
*[step.disp for step in self.steps],
344+
*[step.disp_prime for step in self.steps],
345+
*[step.disp_prep for step in self.steps],
346+
])
347+
348+
def any_wash(self):
349+
return self.wash_prime or any([step.wash for step in self.steps])
350+
351+
def any_blue(self):
352+
return self.use_blue or self.blue_prime or any([step.blue for step in self.steps])
353+
'''
354+
336355
from .protocol_paths import ProtocolPaths, paths_v5
337356

338357
@dataclass(frozen=True)
@@ -462,15 +481,15 @@ def program_test_comm(with_incu: bool=True, with_blue: bool=True) -> Command:
462481
Test communication with robotarm, washer, dispenser and incubator.
463482
'''
464483
return Seq(
465-
# BlueCmd(action='TestCommunications', protocol_path=None).fork() if with_blue else Idle(),
484+
BlueCmd(action='TestCommunications', protocol_path=None).fork() if with_blue else Idle(),
466485
DispCmd(cmd='TestCommunications', protocol_path=None).fork(),
467486
IncuCmd(action='get_status', incu_loc=None).fork() if with_incu else Idle(),
468487
RobotarmCmd('ur gripper init and check'),
469488
WaitForResource('disp'),
470489
WashCmd(cmd='TestCommunications', protocol_path=None).fork(),
471490
WaitForResource('incu') if with_incu else Idle(),
472491
WaitForResource('wash'),
473-
# WaitForResource('blue') if with_blue else Idle(),
492+
WaitForResource('blue') if with_blue else Idle(),
474493
).add(Metadata(step_desc='test comm'))
475494

476495
Desc = tuple[str, str, str]
@@ -509,8 +528,12 @@ def paint_batch(batch: list[Plate], protocol_config: ProtocolConfig) -> Command:
509528
Checkpoint(f'batch {batch_index}'),
510529
]
511530

531+
prep_cmds += [
532+
program_test_comm(with_blue=p.use_blue),
533+
BlueCmd('get_working_plate').fork() if p.use_blue else Idle(),
534+
]
535+
512536
post_cmds = [
513-
Duration(f'batch {batch_index}', OptPrio.batch_time),
514537
]
515538

516539
chunks: dict[Desc, Iterable[Command]] = {}
@@ -580,6 +603,13 @@ def paint_batch(batch: list[Plate], protocol_config: ProtocolConfig) -> Command:
580603
),
581604
]
582605

606+
lid_on_base_B15 = [
607+
*RobotarmCmds(
608+
plate_with_corrected_lid_pos.lid_get_base_B15,
609+
after_drop=[Duration(f'{plate_desc} lid off {ix}', OptPrio.without_lid)]
610+
),
611+
]
612+
583613
if step.name == 'Mito' or step.name == 'PFA':
584614
incu_get = [
585615
# Idle() + 'sep {plate_desc} {step.name}',
@@ -676,7 +706,8 @@ def paint_batch(batch: list[Plate], protocol_config: ProtocolConfig) -> Command:
676706
cmd.add(Metadata(plate_id=None))
677707
for cmd in blue_prime
678708
if plate is first_plate
679-
if not prev_step or not prev_step.blue
709+
# if not prev_step or not prev_step.blue
710+
if step.blue # let's just always prime blue for simplicity
680711
],
681712
BlueCmd('Validate', step.blue),
682713
),
@@ -809,11 +840,11 @@ def blue_to_B(z: int):
809840
chunks[plate.id, step.name, 'blue -> B21' ] = [*blue_to_B(21), *lid_on]
810841
chunks[plate.id, step.name, 'blue -> B15' ] = [*blue_to_B(15)]
811842

812-
if 0 and step.name == 'Mito' and not step.blue and not step.wash:
813-
# exception!
814-
chunks[plate.id, step.name, 'disp -> B15' ] = [*disp_to_B(21), *lid_on, *RobotarmCmds('B15 put')]
843+
if step.disp and not step.blue and not step.wash:
844+
# put on the lid now
845+
chunks[plate.id, step.name, 'disp -> B15' ] = [*disp_to_B(15), *lid_on_base_B15]
815846
chunks[plate.id, step.name, 'B15 -> B21' ] = []
816-
chunks[plate.id, step.name, 'B21 -> incu'] = [*B15_to_incu]
847+
chunks[plate.id, step.name, 'B21 -> incu'] = [*RobotarmCmds('B15 get'), *B21_to_incu]
817848
else:
818849
chunks[plate.id, step.name, 'disp -> B15' ] = [*disp_to_B(15)]
819850
chunks[plate.id, step.name, 'B15 -> B21' ] = [*RobotarmCmds('B15 get'), *lid_on]
@@ -948,11 +979,9 @@ def cell_paint_program(batch_sizes: list[int], protocol_config: ProtocolConfig)
948979
program = Seq(*cmds)
949980
program = Seq(
950981
Checkpoint('run'),
951-
program_test_comm(with_blue=protocol_config.use_blue),
952-
BlueCmd('get_working_plate').fork() if protocol_config.use_blue else Idle(),
953-
WaitForCheckpoint('run') + 'initialization slack',
982+
# we now do test comm at start of each batch
954983
program,
955-
Duration('run', OptPrio.batch_time)
984+
Duration('run', OptPrio.total_time)
956985
)
957986
return Program(
958987
command=program,

cellpainter/cellpainter/protocol_vis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def index() -> Iterator[Tag | dict[str, str]]:
162162
span(f'{delay_secs.value} s'),
163163
),
164164
label(span('zoom: '), zoom_int.range(), span(str(zoom_int.value))),
165-
label(span('pfa duration: '), pfa_duration.range().extend(width=200), span(f'{pfa_duration.value} s')),
165+
# label(span('pfa duration: '), pfa_duration.range().extend(width=200), span(f'{pfa_duration.value} s')),
166166
label(span('vertical: '), vertical.input().extend(style='justify-self: left')),
167167
background='#fff',
168168
border_bottom='1px #0008 solid',

cellpainter/cellpainter/small_protocols.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_comm(_: SmallProtocolArgs):
139139
'''
140140
Test communication with robotarm, washer, dispenser and incubator.
141141
'''
142-
return Program(protocol.program_test_comm().add(Metadata(gui_force_show=True)))
142+
return Program(protocol.program_test_comm(with_blue=False).add(Metadata(gui_force_show=True)))
143143

144144
@ur_protocols.append
145145
def test_circuit(args: SmallProtocolArgs):

cellpainter/movelists/lid-B19.jsonl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{"type":"Section","section":"lid-B19 put"}
22
{"type":"MoveJoint","joints":[94.88,-110.59,90.31,19.45,95.29,179.84],"name":"B neu"}
3-
{"type":"MoveLin","xyz":[199.7,-566.9,834.2],"rpy":[0.0,0.7,89.6],"name":"B21 neu"}
4-
{"type":"MoveLin","xyz":[199.7,-566.9,821.9],"rpy":[0.0,0.7,89.6],"name":"B21 pick","slow":true}
3+
{"type":"MoveLin","xyz":[199.7,-421.7,834.2],"rpy":[0.0,0.7,89.6],"tag":"base 21","name":"B21 entrance"}
4+
{"type":"MoveLin","xyz":[199.7,-566.9,834.2],"rpy":[0.0,0.7,89.6],"tag":"base 21","name":"B21 neu"}
5+
{"type":"MoveLin","xyz":[199.7,-566.9,821.9],"rpy":[0.0,0.7,89.6],"tag":"base 21","name":"B21 pick","slow":true}
56
{"type":"GripperMove","pos":255}
6-
{"type":"MoveLin","xyz":[199.7,-566.9,834.2],"rpy":[0.0,0.7,89.6],"name":"B21 neu"}
7-
{"type":"MoveLin","xyz":[199.7,-421.7,834.2],"rpy":[0.0,0.7,89.6],"name":"B21 entrance"}
7+
{"type":"MoveLin","xyz":[199.7,-566.9,834.2],"rpy":[0.0,0.7,89.6],"tag":"base 21","name":"B21 neu"}
8+
{"type":"MoveLin","xyz":[199.7,-421.7,834.2],"rpy":[0.0,0.7,89.6],"tag":"base 21","name":"B21 entrance"}
89
{"type":"MoveLin","xyz":[199.7,-421.8,751.1],"rpy":[0.0,0.7,89.6],"tag":"19/21","name":"B19 entrance"}
910
{"type":"MoveLin","xyz":[199.7,-567.4,751.1],"rpy":[0.0,0.7,89.6],"tag":"19/21","name":"B19 neu"}
1011
{"type":"MoveLin","xyz":[199.7,-567.4,742.6],"rpy":[0.0,0.7,89.6],"tag":"19/21","name":"B19 drop","slow":true}
@@ -20,9 +21,10 @@
2021
{"type":"GripperMove","pos":255}
2122
{"type":"MoveLin","xyz":[199.7,-567.4,751.1],"rpy":[0.0,0.7,89.6],"tag":"19/21","name":"B19 pick neu"}
2223
{"type":"MoveLin","xyz":[199.7,-421.8,751.1],"rpy":[0.0,0.7,89.6],"tag":"19/21","name":"B19 entrance"}
23-
{"type":"MoveLin","xyz":[199.7,-421.7,834.2],"rpy":[0.0,0.7,89.6],"name":"B21 entrance"}
24-
{"type":"MoveLin","xyz":[199.7,-566.9,834.2],"rpy":[0.0,0.7,89.6],"name":"B21 neu"}
25-
{"type":"MoveLin","xyz":[199.7,-566.9,822.2],"rpy":[0.0,0.7,89.6],"name":"B21 drop","slow":true}
24+
{"type":"MoveLin","xyz":[199.7,-421.7,834.2],"rpy":[0.0,0.7,89.6],"tag":"base 21","name":"B21 entrance"}
25+
{"type":"MoveLin","xyz":[199.7,-566.9,834.2],"rpy":[0.0,0.7,89.6],"tag":"base 21","name":"B21 neu"}
26+
{"type":"MoveLin","xyz":[199.7,-566.9,822.2],"rpy":[0.0,0.7,89.6],"tag":"base 21","name":"B21 drop","slow":true}
2627
{"type":"GripperMove","pos":88}
27-
{"type":"MoveLin","xyz":[199.7,-566.9,834.2],"rpy":[0.0,0.7,89.6],"name":"B21 neu"}
28+
{"type":"MoveLin","xyz":[199.7,-566.9,834.2],"rpy":[0.0,0.7,89.6],"tag":"base 21","name":"B21 neu"}
29+
{"type":"MoveLin","xyz":[199.7,-421.7,834.2],"rpy":[0.0,0.7,89.6],"tag":"base 21","name":"B21 entrance"}
2830
{"type":"MoveLin","xyz":[199.7,-421.7,834.2],"rpy":[0.0,0.8,89.6],"name":"B neu"}

0 commit comments

Comments
 (0)