From d869c353d848809c5538f99763b2c14aed495741 Mon Sep 17 00:00:00 2001 From: Sanniti Date: Tue, 27 Feb 2024 14:01:21 -0500 Subject: [PATCH] switched to using a complete TC lid collision zone --- .../protocol_api/core/engine/deck_conflict.py | 31 +++++++++++++------ .../protocol_engine/state/pipettes.py | 2 ++ .../core/engine/test_deck_conflict.py | 8 ++--- .../opentrons_shared_data/module/__init__.py | 9 ++++++ 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/api/src/opentrons/protocol_api/core/engine/deck_conflict.py b/api/src/opentrons/protocol_api/core/engine/deck_conflict.py index d4b6103649c..dc290fe01ae 100644 --- a/api/src/opentrons/protocol_api/core/engine/deck_conflict.py +++ b/api/src/opentrons/protocol_api/core/engine/deck_conflict.py @@ -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 @@ -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( @@ -343,7 +355,6 @@ 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 @@ -351,14 +362,14 @@ def _will_collide_with_thermocycler_lid( 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 diff --git a/api/src/opentrons/protocol_engine/state/pipettes.py b/api/src/opentrons/protocol_engine/state/pipettes.py index 57b07155549..1628d0e1d21 100644 --- a/api/src/opentrons/protocol_engine/state/pipettes.py +++ b/api/src/opentrons/protocol_engine/state/pipettes.py @@ -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 ) diff --git a/api/tests/opentrons/protocol_api/core/engine/test_deck_conflict.py b/api/tests/opentrons/protocol_api/core/engine/test_deck_conflict.py index 157cde03424..17308531ac8 100644 --- a/api/tests/opentrons/protocol_api/core/engine/test_deck_conflict.py +++ b/api/tests/opentrons/protocol_api/core/engine/test_deck_conflict.py @@ -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( diff --git a/shared-data/python/opentrons_shared_data/module/__init__.py b/shared-data/python/opentrons_shared_data/module/__init__.py index 10117ded8dd..7f3dd0a602f 100644 --- a/shared-data/python/opentrons_shared_data/module/__init__.py +++ b/shared-data/python/opentrons_shared_data/module/__init__.py @@ -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?