Skip to content

Commit

Permalink
refactor(api): Update flex acc speeds based on EE recs (#12946)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahiuchingau authored Jun 21, 2023
1 parent 918b2c1 commit 3424f42
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 48 deletions.
29 changes: 15 additions & 14 deletions api/src/opentrons/config/defaults_ot3.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,20 @@
DEFAULT_GRIPPER_MOUNT_OFFSET: Final[Offset] = (84.55, -12.75, 93.85)
DEFAULT_Z_RETRACT_DISTANCE: Final = 2
DEFAULT_SAFE_HOME_DISTANCE: Final = 5
DEFAULT_CALIBRATION_AXIS_MAX_SPEED: Final = 30

DEFAULT_MAX_SPEEDS: Final[ByGantryLoad[Dict[OT3AxisKind, float]]] = ByGantryLoad(
high_throughput={
OT3AxisKind.X: 375,
OT3AxisKind.Y: 375,
OT3AxisKind.X: 400,
OT3AxisKind.Y: 325,
OT3AxisKind.Z: 35,
OT3AxisKind.P: 5,
OT3AxisKind.Z_G: 50,
OT3AxisKind.Q: 5.5,
},
low_throughput={
OT3AxisKind.X: 375,
OT3AxisKind.Y: 375,
OT3AxisKind.X: 400,
OT3AxisKind.Y: 325,
OT3AxisKind.Z: 100,
OT3AxisKind.P: 45,
OT3AxisKind.Z_G: 50,
Expand All @@ -98,17 +99,17 @@

DEFAULT_ACCELERATIONS: Final[ByGantryLoad[Dict[OT3AxisKind, float]]] = ByGantryLoad(
high_throughput={
OT3AxisKind.X: 600,
OT3AxisKind.Y: 600,
OT3AxisKind.Z: 120,
OT3AxisKind.X: 800,
OT3AxisKind.Y: 500,
OT3AxisKind.Z: 150,
OT3AxisKind.P: 30,
OT3AxisKind.Z_G: 150,
OT3AxisKind.Q: 10,
},
low_throughput={
OT3AxisKind.X: 600,
OT3AxisKind.X: 800,
OT3AxisKind.Y: 600,
OT3AxisKind.Z: 300,
OT3AxisKind.Z: 150,
OT3AxisKind.P: 100,
OT3AxisKind.Z_G: 150,
},
Expand Down Expand Up @@ -174,17 +175,17 @@

DEFAULT_RUN_CURRENT: Final[ByGantryLoad[Dict[OT3AxisKind, float]]] = ByGantryLoad(
high_throughput={
OT3AxisKind.X: 1.4,
OT3AxisKind.X: 1.25,
OT3AxisKind.Y: 1.4,
OT3AxisKind.Z: 1.4,
OT3AxisKind.Z: 1.5,
OT3AxisKind.P: 2.2,
OT3AxisKind.Z_G: 0.67,
OT3AxisKind.Q: 1.5,
},
low_throughput={
OT3AxisKind.X: 1.4,
OT3AxisKind.Y: 1.4,
OT3AxisKind.Z: 1.4,
OT3AxisKind.X: 1.25,
OT3AxisKind.Y: 1.25,
OT3AxisKind.Z: 1.0,
# TODO: verify this value
OT3AxisKind.P: 1.0,
OT3AxisKind.Z_G: 0.67,
Expand Down
24 changes: 24 additions & 0 deletions api/src/opentrons/hardware_control/backends/ot3utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Shared utilities for ot3 hardware control."""
from typing import Dict, Iterable, List, Set, Tuple, TypeVar, Sequence
from typing_extensions import Literal
from opentrons.config.defaults_ot3 import DEFAULT_CALIBRATION_AXIS_MAX_SPEED
from opentrons.config.types import OT3MotionSettings, OT3CurrentSettings, GantryLoad
from opentrons.hardware_control.types import (
OT3Axis,
Expand Down Expand Up @@ -235,6 +236,29 @@ def get_system_constraints(
return constraints


def get_system_constraints_for_calibration(
config: OT3MotionSettings,
gantry_load: GantryLoad,
) -> "SystemConstraints[OT3Axis]":
conf_by_pip = config.by_gantry_load(gantry_load)
constraints = {}
for axis_kind in [
OT3AxisKind.P,
OT3AxisKind.X,
OT3AxisKind.Y,
OT3AxisKind.Z,
OT3AxisKind.Z_G,
]:
for axis in OT3Axis.of_kind(axis_kind):
constraints[axis] = AxisConstraints.build(
conf_by_pip["acceleration"][axis_kind],
conf_by_pip["max_speed_discontinuity"][axis_kind],
conf_by_pip["direction_change_speed_discontinuity"][axis_kind],
DEFAULT_CALIBRATION_AXIS_MAX_SPEED,
)
return constraints


def _convert_to_node_id_dict(
axis_pos: Coordinates[OT3Axis, CoordinateValue],
) -> NodeIdMotionValues:
Expand Down
50 changes: 26 additions & 24 deletions api/src/opentrons/hardware_control/ot3_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,30 +564,32 @@ async def _calibrate_mount(
from the current instrument offset to set a new instrument offset.
"""
nominal_center = Point(*get_calibration_square_position_in_slot(slot))
try:
# find the center of the calibration sqaure
offset = await find_calibration_structure_position(
hcapi,
mount,
nominal_center,
method=method,
raise_verify_error=raise_verify_error,
)
# update center with values obtained during calibration
LOG.info(f"Found calibration value {offset} for mount {mount.name}")
return offset

except (
InaccurateNonContactSweepError,
EarlyCapacitiveSenseTrigger,
CalibrationStructureNotFoundError,
):
LOG.info(
"Error occurred during calibration. Resetting to current saved calibration value."
)
await hcapi.reset_instrument_offset(mount, to_default=False)
# re-raise exception after resetting instrument offset
raise
async with hcapi.restore_system_constrants():
await hcapi.set_system_constraints_for_calibration()
try:
# find the center of the calibration sqaure
offset = await find_calibration_structure_position(
hcapi,
mount,
nominal_center,
method=method,
raise_verify_error=raise_verify_error,
)
# update center with values obtained during calibration
LOG.info(f"Found calibration value {offset} for mount {mount.name}")
return offset

except (
InaccurateNonContactSweepError,
EarlyCapacitiveSenseTrigger,
CalibrationStructureNotFoundError,
):
LOG.info(
"Error occurred during calibration. Resetting to current saved calibration value."
)
await hcapi.reset_instrument_offset(mount, to_default=False)
# re-raise exception after resetting instrument offset
raise


async def find_calibration_structure_position(
Expand Down
23 changes: 23 additions & 0 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from functools import partial, lru_cache
from dataclasses import replace
import logging
from copy import deepcopy
from collections import OrderedDict
from typing import (
AsyncIterator,
Expand Down Expand Up @@ -63,6 +64,7 @@
from .backends.ot3simulator import OT3Simulator
from .backends.ot3utils import (
get_system_constraints,
get_system_constraints_for_calibration,
axis_convert,
)
from .backends.errors import SubsystemUpdating
Expand Down Expand Up @@ -239,6 +241,27 @@ async def set_gantry_load(self, gantry_load: GantryLoad) -> None:
)
await self._backend.update_to_default_current_settings(gantry_load)

async def set_system_constraints_for_calibration(self) -> None:
self._move_manager.update_constraints(
get_system_constraints_for_calibration(
self._config.motion_settings, self._gantry_load
)
)
mod_log.debug(
f"Set system constraints for calibration: {self._move_manager.get_constraints()}"
)

@contextlib.asynccontextmanager
async def restore_system_constrants(self) -> AsyncIterator[None]:
old_system_constraints = deepcopy(self._move_manager.get_constraints())
try:
yield
finally:
self._move_manager.update_constraints(old_system_constraints)
mod_log.debug(
f"Restore previous system constraints: {old_system_constraints}"
)

def _update_door_state(self, door_state: DoorState) -> None:
mod_log.info(f"Updating the window switch status: {door_state}")
self.door_state = door_state
Expand Down
20 changes: 10 additions & 10 deletions hardware-testing/hardware_testing/gravimetric/overrides/api.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@ index 89696c5b2a..4c2d6184b8 100644
--- a/api/src/opentrons/config/defaults_ot3.py
+++ b/api/src/opentrons/config/defaults_ot3.py
@@ -83,7 +83,7 @@ DEFAULT_MAX_SPEEDS: Final[ByGantryLoad[Dict[OT3AxisKind, float]]] = ByGantryLoad
OT3AxisKind.X: 375,
OT3AxisKind.Y: 375,
OT3AxisKind.X: 400,
OT3AxisKind.Y: 325,
OT3AxisKind.Z: 35,
- OT3AxisKind.P: 5,
+ OT3AxisKind.P: 20,
OT3AxisKind.Z_G: 50,
OT3AxisKind.Q: 5.5,
},
@@ -98,18 +98,18 @@ DEFAULT_MAX_SPEEDS: Final[ByGantryLoad[Dict[OT3AxisKind, float]]] = ByGantryLoad
@@ -100,18 +100,18 @@ DEFAULT_MAX_SPEEDS: Final[ByGantryLoad[Dict[OT3AxisKind, float]]] = ByGantryLoad

DEFAULT_ACCELERATIONS: Final[ByGantryLoad[Dict[OT3AxisKind, float]]] = ByGantryLoad(
high_throughput={
- OT3AxisKind.X: 600,
- OT3AxisKind.Y: 600,
- OT3AxisKind.X: 800,
- OT3AxisKind.Y: 500,
+ OT3AxisKind.X: 500,
+ OT3AxisKind.Y: 500,
OT3AxisKind.Z: 120,
OT3AxisKind.Z: 150,
- OT3AxisKind.P: 30,
+ OT3AxisKind.P: 1000,
OT3AxisKind.Z_G: 150,
OT3AxisKind.Q: 10,
},
low_throughput={
- OT3AxisKind.X: 600,
- OT3AxisKind.X: 800,
- OT3AxisKind.Y: 600,
+ OT3AxisKind.X: 500,
+ OT3AxisKind.Y: 200,
OT3AxisKind.Z: 300,
OT3AxisKind.Z: 150,
- OT3AxisKind.P: 100,
+ OT3AxisKind.P: 1500,
OT3AxisKind.Z_G: 150,
Expand All @@ -47,9 +47,9 @@ index 89696c5b2a..4c2d6184b8 100644
OT3AxisKind.Q: 5,
@@ -176,8 +176,8 @@ DEFAULT_RUN_CURRENT: Final[ByGantryLoad[Dict[OT3AxisKind, float]]] = ByGantryLoa
high_throughput={
OT3AxisKind.X: 1.4,
OT3AxisKind.X: 1.25,
OT3AxisKind.Y: 1.4,
- OT3AxisKind.Z: 1.4,
- OT3AxisKind.Z: 1.5,
- OT3AxisKind.P: 2.2,
+ OT3AxisKind.Z: 1.5,
+ OT3AxisKind.P: 0.8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def update_constraints(self, constraints: SystemConstraints[AxisKey]) -> None:
"""Update system constraints when instruments are changed."""
self._constraints = constraints

def get_constraints(self) -> SystemConstraints[AxisKey]:
"""Retrieve current system constraints."""
return self._constraints

def _clear_blend_log(self) -> None:
"""Empty the blend log."""
self._blend_log = []
Expand Down

0 comments on commit 3424f42

Please sign in to comment.