Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): pass the calibrated jaw max offset value when we resetting instrument #15032

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
Geometry,
)

RECONFIG_KEYS = {"quirks"}
RECONFIG_KEYS = {"quirks", "grip_force_profile"}

MAX_ACCEPTABLE_JAW_DISPLACEMENT: Final = 20

Expand All @@ -52,6 +52,7 @@ def __init__(
config: GripperDefinition,
gripper_cal_offset: GripperCalibrationOffset,
gripper_id: str,
jaw_max_offset: Optional[float] = None,
) -> None:
self._config = config
self._model = config.model
Expand Down Expand Up @@ -83,7 +84,7 @@ def __init__(
self._log.info(
f"loaded: {self._model}, gripper offset: {self._calibration_offset}"
)
self._jaw_max_offset: Optional[float] = None
self._jaw_max_offset = jaw_max_offset

@property
def grip_force_profile(self) -> GripForceProfile:
Expand Down Expand Up @@ -325,11 +326,13 @@ def _reload_gripper(
changed.add(k)
if changed.intersection(RECONFIG_KEYS):
# Something has changed that requires reconfig
# we shoud recalibrate the jaw as well
return (
Gripper(
new_config,
cal_offset,
attached_instr._gripper_id,
None,
),
False,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def reset_gripper(self) -> None:
og_gripper.config,
load_gripper_calibration_offset(og_gripper.gripper_id),
og_gripper.gripper_id,
og_gripper._jaw_max_offset,
)
self._gripper = new_gripper

Expand Down
28 changes: 28 additions & 0 deletions api/tests/opentrons/hardware_control/test_gripper.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def test_reload_instrument_cal_ot3(fake_offset: "GripperCalibrationOffset") -> N
fake_gripper_conf,
fake_offset,
"fakeid123",
jaw_max_offset=15,
)
# if only calibration is changed
new_cal = instrument_calibration.GripperCalibrationOffset(
Expand All @@ -87,10 +88,37 @@ def test_reload_instrument_cal_ot3(fake_offset: "GripperCalibrationOffset") -> N

# it's the same gripper
assert new_gripper == old_gripper
# jaw offset should persists as well
assert new_gripper._jaw_max_offset == old_gripper._jaw_max_offset
# we said upstream could skip
assert skip


@pytest.mark.ot3_only
def test_reload_instrument_cal_ot3_conf_changed(
fake_offset: "GripperCalibrationOffset",
) -> None:
old_gripper = gripper.Gripper(
fake_gripper_conf,
fake_offset,
"fakeid123",
jaw_max_offset=15,
)
new_conf = fake_gripper_conf.copy(
update={"grip_force_profile": {"default_grip_force": 1}}
)
assert new_conf != old_gripper.config

new_gripper, skip = gripper._reload_gripper(new_conf, old_gripper, fake_offset)

# it's not the same gripper
assert new_gripper != old_gripper
# do not pass in the old jaw max offse
assert not new_gripper._jaw_max_offset
# we said upstream could skip
assert not skip


@pytest.mark.ot3_only
def test_jaw_calibration_error_checking() -> None:
subject = gripper.Gripper(fake_gripper_conf, fake_offset, "fakeid123")
Expand Down
Loading