Ejemplo n.º 1
0
def test_add():
    state = init()
    assert state == {
        ROOT: Node(parent=None,
                   children=[],
                   transform=translate(Point(0, 0, 0)))
    }
    state = add(state, obj='child', point=Point(1, 2, 3))
    assert state == {
        ROOT:
        Node(parent=None,
             children=['child'],
             transform=translate(Point(0, 0, 0))),
        'child':
        Node(parent=ROOT, children=[], transform=translate(Point(-1, -2, -3)))
    }

    with pytest.raises(AssertionError):
        add(state, obj='child', point=Point(1, 2, 3))

    with pytest.raises(KeyError):
        add(state,
            obj='new-child',
            parent='another-root',
            point=Point(1, 2, 3))
Ejemplo n.º 2
0
def state():
    return init() \
        .add('1', point=Point(1, 2, 3)) \
        .add('2', point=Point(-1, -2, -3)) \
        .add('1-1', parent='1', point=Point(11, 12, 13)) \
        .add('1-1-1', parent='1-1', point=Point(0, 0, 0)) \
        .add('1-2', parent='1', point=Point(21, 22, 23)) \
        .add('2-1', parent='2', point=Point(-11, -12, -13)) \
        .add('2-2', parent='2', point=Point(-21, -22, -23))
Ejemplo n.º 3
0
def test_functional(smoothie):
    scale = array([
        [2, 0, 0, -1],
        [0, 2, 0, -2],
        [0, 0, 2, -3],
        [0, 0, 0, 1],
    ])

    back = array([
        [0.5, 0, 0, 0],
        [0, 0.5, 0, 0],
        [0, 0, 0.5, 0],
        [0, 0, 0, 1],
    ])

    left = Mover(driver=smoothie,
                 axis_mapping={'z': 'Z'},
                 src=ROOT,
                 dst=id(scale))
    right = Mover(driver=smoothie,
                  axis_mapping={'z': 'A'},
                  src=ROOT,
                  dst=id(scale))
    gantry = Mover(
        driver=smoothie,
        axis_mapping={
            'x': 'X',
            'y': 'Y'
        },
        src=ROOT,
        dst=id(scale),
    )

    state = init() \
        .add(id(scale), transform=scale) \
        .add(gantry, id(scale)) \
        .add(left, gantry) \
        .add(right, gantry) \
        .add('left', left, transform=back) \
        .add('right', right, transform=back)

    state = gantry.move(state, x=1, y=1)
    state = left.move(state, z=1)

    assert isclose(change_base(state, src='left'), (1, 1, 1)).all()
    assert isclose(change_base(state, src='right'), (1, 1, 1.5)).all()
    state = gantry.move(state, x=2, y=2)
    state = right.move(state, z=3)
    assert isclose(change_base(state, src='left'), (2, 2, 1)).all()
    assert isclose(change_base(state, src='right'), (2, 2, 3)).all()
    state = gantry.jog(state, axis='x', distance=1)
    assert isclose(change_base(state, src='left'), (3, 2, 1)).all()
    assert isclose(change_base(state, src='right'), (3, 2, 3)).all()
    state = right.jog(state, axis='z', distance=1)
    assert isclose(change_base(state, src='left'), (3, 2, 1)).all()
    assert isclose(change_base(state, src='right'), (3, 2, 4)).all()
Ejemplo n.º 4
0
def test_relative(state):
    from math import pi
    assert (change_base(state, src='1-1', dst='2-1') == (24., 28., 32.)).all()
    state = \
        init() \
        .add('1', transform=rotate(pi / 2.0)) \
        .add('1-1', parent='1', point=Point(1, 0, 0)) \
        .add('2', point=Point(1, 0, 0))

    assert isclose(change_base(state, src='1-1', dst='2'),
                   (-1.0, -1.0, 0)).all()
    assert isclose(change_base(state, src='2', dst='1-1'), (0.0, 0.0, 0)).all()

    state = init() \
        .add('1', transform=scale(2, 1, 1)) \
        .add('1-1', parent='1', point=Point(1, 1, 1)) \

    assert isclose(change_base(state, src=ROOT, dst='1-1'),
                   (-2.0, -1.0, -1.0)).all()
    assert isclose(change_base(state, src='1-1', dst=ROOT),
                   (0.5, 1.0, 1.0)).all()
Ejemplo n.º 5
0
def test_change_base():
    state = init() \
        .add('1', parent=ROOT, transform=scale(2, 2, 2)) \
        .add('1-1', parent='1', point=Point(1, 0, 0))

    assert isclose(change_base(state, src='1-1'), (0.5, 0, 0)).all()
Ejemplo n.º 6
0
    def reset(self):
        """
        Resets the state of the robot and clears:
            * Deck
            * Instruments
            * Command queue
            * Runtime warnings

        Examples
        --------

        >>> from opentrons import robot # doctest: +SKIP
        >>> robot.reset() # doctest: +SKIP
        """
        self._gantry_cal_id = id(self.config.gantry_calibration)
        self._actuators = {
            'left': {
                'carriage':
                Mover(driver=self._driver,
                      src=pose_tracker.ROOT,
                      dst=self._gantry_cal_id,
                      axis_mapping={'z': 'Z'}),
                'plunger':
                Mover(driver=self._driver,
                      src=pose_tracker.ROOT,
                      dst='volume-calibration-left',
                      axis_mapping={'x': 'B'})
            },
            'right': {
                'carriage':
                Mover(driver=self._driver,
                      src=pose_tracker.ROOT,
                      dst=self._gantry_cal_id,
                      axis_mapping={'z': 'A'}),
                'plunger':
                Mover(driver=self._driver,
                      src=pose_tracker.ROOT,
                      dst='volume-calibration-right',
                      axis_mapping={'x': 'C'})
            }
        }
        self.clear_tips()

        self.poses = pose_tracker.init()

        self._runtime_warnings = []

        self._deck = containers.Deck()
        self._fixed_trash = None
        self.setup_deck()
        self.setup_gantry()
        self._instruments = {}

        self._use_safest_height = False

        self._previous_instrument = None
        self._prev_container = None

        # TODO: Move homing info to driver
        self.axis_homed = {
            'x': False,
            'y': False,
            'z': False,
            'a': False,
            'b': False
        }

        self.clear_commands()

        # update the position of each Mover
        self._driver.update_position()
        for mount in self._actuators.values():
            for mover in mount.values():
                self.poses = mover.update_pose_from_driver(self.poses)
        self.cache_instrument_models()

        return self