Skip to content

Commit

Permalink
fix(engine): fix labware gripperOffsets not allowing only a default o…
Browse files Browse the repository at this point in the history
…ffset (#13472)
  • Loading branch information
jbleon95 authored Sep 7, 2023
1 parent a04c8d0 commit bd7f541
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
10 changes: 5 additions & 5 deletions api/src/opentrons/protocol_engine/state/labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,18 +751,18 @@ def get_labware_gripper_offsets(
"""Get the labware's gripper offsets of the specified type."""
parsed_offsets = self.get_definition(labware_id).gripperOffsets
offset_key = slot_name.name if slot_name else "default"
return (
LabwareMovementOffsetData(

if parsed_offsets is None or offset_key not in parsed_offsets:
return None
else:
return LabwareMovementOffsetData(
pickUpOffset=cast(
LabwareOffsetVector, parsed_offsets[offset_key].pickUpOffset
),
dropOffset=cast(
LabwareOffsetVector, parsed_offsets[offset_key].dropOffset
),
)
if parsed_offsets
else None
)

def get_grip_force(self, labware_id: str) -> float:
"""Get the recommended grip force for gripping labware using gripper."""
Expand Down
45 changes: 45 additions & 0 deletions api/tests/opentrons/protocol_engine/state/test_labware_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
Parameters,
LabwareRole,
OverlapOffset as SharedDataOverlapOffset,
GripperOffsets,
OffsetVector,
)
from opentrons.protocols.models import LabwareDefinition
from opentrons.types import DeckSlotName, Point, MountType
Expand Down Expand Up @@ -1346,6 +1348,49 @@ def test_get_labware_gripper_offsets(
)


def test_get_labware_gripper_offsets_default_no_slots(
well_plate_def: LabwareDefinition,
adapter_plate_def: LabwareDefinition,
) -> None:
"""It should get the labware's gripper offsets with only a default gripper offset entry."""
subject = get_labware_view(
labware_by_id={
"labware-id": LoadedLabware(
id="labware-id",
loadName="labware-load-name",
location=DeckSlotLocation(slotName=DeckSlotName.SLOT_1),
definitionUri="some-labware-uri",
offsetId=None,
displayName="Fancy Labware Name",
)
},
definitions_by_uri={
"some-labware-uri": LabwareDefinition.construct( # type: ignore[call-arg]
gripperOffsets={
"default": GripperOffsets(
pickUpOffset=OffsetVector(x=1, y=2, z=3),
dropOffset=OffsetVector(x=4, y=5, z=6),
)
}
),
},
)

assert (
subject.get_labware_gripper_offsets(
labware_id="labware-id", slot_name=DeckSlotName.SLOT_D1
)
is None
)

assert subject.get_labware_gripper_offsets(
labware_id="labware-id", slot_name=None
) == LabwareMovementOffsetData(
pickUpOffset=LabwareOffsetVector(x=1, y=2, z=3),
dropOffset=LabwareOffsetVector(x=4, y=5, z=6),
)


def test_get_grip_force(
flex_50uL_tiprack: LabwareDefinition,
reservoir_def: LabwareDefinition,
Expand Down

0 comments on commit bd7f541

Please sign in to comment.