Skip to content

Commit

Permalink
feat(api): warn tc-lid/gantry collision in simulation
Browse files Browse the repository at this point in the history
If a given protocol would target the labware loaded into a thermocycler module, while that module is
known to be closed, simulation will fail with a helpful message.

Closes #4044
  • Loading branch information
b-cooper committed Nov 6, 2019
1 parent c3b25b0 commit 3ca82cf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
15 changes: 15 additions & 0 deletions api/src/opentrons/protocol_api/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,21 @@ def move_to(self, location: types.Location, force_direct: bool = False,
self._mount, critical_point=cp_override),
from_lw)

self._log.debug(f"\n\n\n\nlocation.labware: {location.labware}")
if location.labware:
self._log.debug(f"location.labware.parent: {location.labware.parent}")
self._log.debug(f"ctx modules: {self._ctx._modules}")

to_lw, to_well = geometry.split_loc_labware(location)
if isinstance(to_lw, Labware) and \
isinstance(to_lw.parent, ThermocyclerGeometry):
tc_context = next(m for m in self._ctx._modules \
if isinstance(m._module, modules.thermocycler.Thermocycler))
if tc_context and tc_context.lid_position == 'closed':
raise RuntimeError(
"Cannot move to labware loaded in Thermocycler"\
" when lid is closed")

moves = geometry.plan_moves(from_loc, location, self._ctx.deck,
force_direct=force_direct,
minimum_z_height=minimum_z_height)
Expand Down
23 changes: 12 additions & 11 deletions api/src/opentrons/protocol_api/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ def max_many(*args):
return functools.reduce(max, args[1:], args[0])


def split_loc_labware(
loc: types.Location) -> Tuple[Optional[Labware], Optional[Well]]:
if isinstance(loc.labware, Labware):
return loc.labware, None
elif isinstance(loc.labware, Well):
return loc.labware.parent, loc.labware
else:
return None, None


def plan_moves(
from_loc: types.Location,
to_loc: types.Location,
Expand Down Expand Up @@ -54,19 +64,10 @@ def plan_moves(

assert minimum_z_height is None or minimum_z_height >= 0.0

def _split_loc_labware(
loc: types.Location) -> Tuple[Optional[Labware], Optional[Well]]:
if isinstance(loc.labware, Labware):
return loc.labware, None
elif isinstance(loc.labware, Well):
return loc.labware.parent, loc.labware
else:
return None, None

to_point = to_loc.point
to_lw, to_well = _split_loc_labware(to_loc)
to_lw, to_well = split_loc_labware(to_loc)
from_point = from_loc.point
from_lw, from_well = _split_loc_labware(from_loc)
from_lw, from_well = split_loc_labware(from_loc)
dest_quirks = quirks_from_any_parent(to_lw)
from_quirks = quirks_from_any_parent(from_lw)
from_center = 'centerMultichannelOnWells' in from_quirks
Expand Down

0 comments on commit 3ca82cf

Please sign in to comment.