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): bump y max bounds to match robot geometry #7140

Merged
merged 2 commits into from
Jan 4, 2021
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
25 changes: 24 additions & 1 deletion api/src/opentrons/drivers/smoothie_drivers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
from typing_extensions import Final


HOMED_POSITION: Final = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI, we might want to check these numbers. Most of these match nominal home of my OT-2, but not all of them...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bunch of weirdness going on with these, and in the actual running smoothie driver they get updated from the results of doing the actual home(). I hate all of this.

'X': 418.0,
'Y': 353.0,
'Z': 218.0,
'A': 218.0,
'B': 19.0,
'C': 19.0
}
Y_BOUND_OVERRIDE: Final = 370


class SmoothieDriver(object):

def __init__(self):
Expand All @@ -13,7 +27,6 @@ def __init__(self):
class SimulatingDriver:
def __init__(self):
self._steps_per_mm = {}
self.homed_position = {}

def home(self, axis):
pass
Expand Down Expand Up @@ -81,3 +94,13 @@ def set_dwelling_current(self, settings):

def set_acceleration(self, settings):
pass

@property
def homed_position(self):
return HOMED_POSITION.copy()

@property
def axis_bounds(self):
position = HOMED_POSITION.copy()
position['Y'] = Y_BOUND_OVERRIDE
return position
24 changes: 11 additions & 13 deletions api/src/opentrons/drivers/smoothie_drivers/driver_3_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from time import sleep, time
from threading import Event, RLock
from typing import Any, Dict, Optional, Union, List, Tuple, cast

from math import isclose
from serial.serialutil import SerialException # type: ignore

Expand All @@ -17,6 +18,9 @@
from opentrons.drivers.rpi_drivers.gpio_simulator import SimulatingGPIOCharDev
from opentrons.drivers.rpi_drivers.dev_types import GPIODriverLike
from opentrons.system import smoothie_update
from . import HOMED_POSITION, Y_BOUND_OVERRIDE


"""
- Driver is responsible for providing an interface for motion control
- Driver is the only system component that knows about GCODES or how smoothie
Expand All @@ -31,18 +35,6 @@
ERROR_KEYWORD = 'error'
ALARM_KEYWORD = 'alarm'


# TODO (artyom, ben 20171026): move to config
HOMED_POSITION: Dict[str, float] = {
'X': 418,
'Y': 353,
'Z': 218,
'A': 218,
'B': 19,
'C': 19
}


PLUNGER_BACKLASH_MM = 0.3
LOW_CURRENT_Z_SPEED = 30
CURRENT_CHANGE_DELAY = 0.005
Expand Down Expand Up @@ -415,9 +407,15 @@ def gpio_chardev(self, gpio_chardev):
self._gpio_chardev = gpio_chardev

@property
def homed_position(self):
def homed_position(self) -> Dict[str, float]:
return self._homed_position.copy()

@property
def axis_bounds(self) -> Dict[str, float]:
bounds = {k: v for k, v in self._homed_position.items()}
bounds['Y'] = Y_BOUND_OVERRIDE
return bounds

def _update_position(self, target):
self._position.update({
axis: value
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/hardware_control/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ async def connect(self, port: str = None):
def axis_bounds(self) -> Dict[Axis, Tuple[float, float]]:
""" The (minimum, maximum) bounds for each axis. """
return {Axis[ax]: (0, pos) for ax, pos
in self._smoothie_driver.homed_position.items()
in self._smoothie_driver.axis_bounds.items()
if ax not in 'BC'}

@property
Expand Down
22 changes: 10 additions & 12 deletions api/src/opentrons/hardware_control/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from threading import Event
from typing import (Dict, Optional, List, Tuple,
TYPE_CHECKING, Sequence)
from typing_extensions import Final
from contextlib import contextmanager

from opentrons_shared_data.pipette import dummy_model_for_name
Expand All @@ -17,6 +16,7 @@
load)
from opentrons.config.types import RobotConfig
from opentrons.drivers.smoothie_drivers import SimulatingDriver

from opentrons.drivers.rpi_drivers.gpio_simulator import SimulatingGPIOCharDev

from . import modules
Expand All @@ -36,10 +36,6 @@
MODULE_LOG = logging.getLogger(__name__)


_HOME_POSITION = {'X': 418.0, 'Y': 353.0, 'Z': 218.0,
'A': 218.0, 'B': 19.0, 'C': 19.0}


class Simulator:
""" This is a subclass of hardware_control that only simulates the
hardware actions. It is suitable for use on a dev machine or on
Expand Down Expand Up @@ -116,7 +112,8 @@ def __init__(
"""
self.config = config
self._loop = loop
self._gpio_chardev: Final = gpio_chardev
self._smoothie_driver = SimulatingDriver()
self._gpio_chardev = gpio_chardev

def _sanitize_attached_instrument(
passed_ai: Dict[str, Optional[str]] = None)\
Expand All @@ -139,13 +136,13 @@ def _sanitize_attached_instrument(
m: _sanitize_attached_instrument(attached_instruments.get(m))
for m in types.Mount}
self._stubbed_attached_modules = attached_modules
self._position = copy.copy(_HOME_POSITION)
self._position = copy.copy(self._smoothie_driver.homed_position)
# Engaged axes start all true in smoothie for some reason so we
# imitate that here
# TODO(LC2642019) Create a simulating driver for smoothie instead of
# using a flag
self._smoothie_driver = SimulatingDriver()
self._engaged_axes = {ax: True for ax in _HOME_POSITION}

self._engaged_axes = {ax: True for ax in self._smoothie_driver.homed_position}
self._lights = {'button': False, 'rails': False}
self._run_flag = Event()
self._run_flag.set()
Expand All @@ -169,7 +166,7 @@ def move(self, target_position: Dict[str, float],
def home(self, axes: List[str] = None) -> Dict[str, float]:
# driver_3_0-> HOMED_POSITION
checked_axes = axes or 'XYZABC'
self._position.update({ax: _HOME_POSITION[ax]
self._position.update({ax: self._smoothie_driver.homed_position[ax]
for ax in checked_axes})
self._engaged_axes.update({ax: True
for ax in checked_axes})
Expand All @@ -178,7 +175,7 @@ def home(self, axes: List[str] = None) -> Dict[str, float]:
def fast_home(
self, axis: Sequence[str], margin: float) -> Dict[str, float]:
for ax in axis:
self._position[ax] = _HOME_POSITION[ax]
self._position[ax] = self._smoothie_driver.homed_position[ax]
self._engaged_axes[ax] = True
return self._position

Expand Down Expand Up @@ -288,7 +285,8 @@ async def build_module(
@property
def axis_bounds(self) -> Dict[Axis, Tuple[float, float]]:
""" The (minimum, maximum) bounds for each axis. """
return {Axis[ax]: (0, pos) for ax, pos in _HOME_POSITION.items()
return {Axis[ax]: (0, pos) for ax, pos
in self._smoothie_driver.axis_bounds.items()
if ax not in 'BC'}

@property
Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/tools/overnight_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
attempts_to_home = 1
too_many_attempts_to_home = 3

XY_TOLERANCE = 30
ZA_TOLERANCE = 10
XY_TOLERANCE = 30.0
ZA_TOLERANCE = 10.0

AXIS_TEST_SKIPPING_TOLERANCE = 0.5

Expand Down