Skip to content

Commit

Permalink
switched to using a complete TC lid collision zone
Browse files Browse the repository at this point in the history
  • Loading branch information
sanni-t committed Feb 27, 2024
1 parent 6ef1a90 commit d869c35
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
31 changes: 21 additions & 10 deletions api/src/opentrons/protocol_api/core/engine/deck_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)

from opentrons_shared_data.errors.exceptions import MotionPlanningFailureError
from opentrons_shared_data.module import FLEX_TC_LID_CLIP_POSITIONS_IN_DECK_COORDINATES
from opentrons_shared_data.module import FLEX_TC_LID_COLLISION_ZONE

from opentrons.hardware_control.nozzle_manager import NozzleConfigurationType
from opentrons.hardware_control.modules.types import ModuleType
Expand Down Expand Up @@ -82,6 +82,18 @@ def __init__(self, message: str) -> None:
# Arbitrary safety margin in z-direction
Z_SAFETY_MARGIN = 10

_FLEX_TC_LID_BACK_LEFT_PT = Point(
x=FLEX_TC_LID_COLLISION_ZONE["back_left"]["x"],
y=FLEX_TC_LID_COLLISION_ZONE["back_left"]["y"],
z=FLEX_TC_LID_COLLISION_ZONE["back_left"]["z"],
)

_FLEX_TC_LID_FRONT_RIGHT_PT = Point(
x=FLEX_TC_LID_COLLISION_ZONE["front_right"]["x"],
y=FLEX_TC_LID_COLLISION_ZONE["front_right"]["y"],
z=FLEX_TC_LID_COLLISION_ZONE["front_right"]["z"],
)


@overload
def check(
Expand Down Expand Up @@ -343,22 +355,21 @@ def _will_collide_with_thermocycler_lid(
and a crude check that disallows all partial tip movements around the thermocycler.
"""
# TODO (spp, 2024-02-27): Improvements:
# - create a complete no-go zone that includes the lid itself
# - make the check dynamic according to lid state:
# - if lid is open, check if pipette is in no-go zone
# - if lid is closed, use the closed lid height to check for conflict
if (
DeckSlotName.SLOT_A1 in surrounding_regular_slots
and engine_state.modules.is_flex_deck_with_thermocycler()
):
tc_right_clip_pos = FLEX_TC_LID_CLIP_POSITIONS_IN_DECK_COORDINATES["right_clip"]
for bound_vertex in pipette_bounds:
if (
bound_vertex.x <= tc_right_clip_pos["x"]
and bound_vertex.y >= tc_right_clip_pos["y"]
and bound_vertex.z <= tc_right_clip_pos["z"]
):
return True
return (
point_calculations.are_overlapping_rectangles(
rectangle1=(_FLEX_TC_LID_BACK_LEFT_PT, _FLEX_TC_LID_FRONT_RIGHT_PT),
rectangle2=(pipette_bounds[0], pipette_bounds[1]),
)
and pipette_bounds[0].z <= _FLEX_TC_LID_BACK_LEFT_PT.z
)

return False


Expand Down
2 changes: 2 additions & 0 deletions api/src/opentrons/protocol_engine/state/pipettes.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,8 @@ def get_pipette_bounds_at_specified_move_to_position(
- primary_nozzle_offset
+ pipette_bounds_offsets.front_right_corner
)
# TODO (spp, 2024-02-27): remove back right & front left;
# return only back left and front right points.
pip_back_right_bound = Point(
pip_front_right_bound.x, pip_back_left_bound.y, pip_front_right_bound.z
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,10 @@ def test_deck_conflict_raises_for_collision_with_tc_lid(
"""It should raise an error if pipette might collide with thermocycler lid on the Flex."""
destination_well_point = Point(x=123, y=123, z=123)
pipette_bounds_at_destination = (
Point(x=50, y=150, z=60),
Point(x=150, y=50, z=60),
Point(x=97, y=403, z=204.5),
Point(x=50, y=50, z=60),
Point(x=50, y=350, z=204.5),
Point(x=150, y=450, z=204.5),
Point(x=150, y=400, z=204.5),
Point(x=50, y=300, z=204.5),
)

decoy.when(
Expand Down
9 changes: 9 additions & 0 deletions shared-data/python/opentrons_shared_data/module/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
"left_clip": {"x": -3.25, "y": 402, "z": 205},
"right_clip": {"x": 97.75, "y": 402, "z": 205},
}
FLEX_TC_LID_COLLISION_ZONE = {
"back_left": {"x": -43.25, "y": 454.9, "z": 211.91},
"front_right": {"x": 128.75, "y": 402, "z": 211.91},
}
"""
Deck co-ordinates of the top plane of TC lid + lid clips
of a thermocycler on a Flex.
"""


# TODO (spp, 2022-05-12): Python has a built-in error called `ModuleNotFoundError` so,
# maybe rename this one?
Expand Down

0 comments on commit d869c35

Please sign in to comment.