Ejemplo n.º 1
0
    def move_to(self, location, instrument, strategy='arc', **kwargs):
        """
        Move an instrument to a coordinate, container or a coordinate within
        a container.

        Parameters
        ----------
        location : one of the following:
            1. :class:`Placeable` (i.e. Container, Deck, Slot, Well) — will
            move to the origin of a container.
            2. :class:`Vector` move to the given coordinate in Deck coordinate
            system.
            3. (:class:`Placeable`, :class:`Vector`) move to a given coordinate
            within object's coordinate system.

        instrument :
            Instrument to move relative to. If ``None``, move relative to the
            center of a gantry.

        strategy : {'arc', 'direct'}
            ``arc`` : move to the point using arc trajectory
            avoiding obstacles.

            ``direct`` : move to the point in a straight line.
        """

        placeable, coordinates = containers.unpack_location(location)

        # because the top position is what is tracked,
        # this checks if coordinates doesn't equal top
        offset = subtract(coordinates, placeable.top()[1])

        if isinstance(placeable, containers.WellSeries):
            placeable = placeable[0]

        target = add(pose_tracker.absolute(self.poses, placeable),
                     offset.coordinates)

        if self._previous_instrument:
            if self._previous_instrument != instrument:
                self._previous_instrument.retract()
                # because we're switching pipettes, this ensures a large (safe)
                # Z arc height will be used for the new pipette
                self._prev_container = None

        self._previous_instrument = instrument

        if strategy == 'arc':
            arc_coords = self._create_arc(instrument, target, placeable)
            for coord in arc_coords:
                self.poses = instrument._move(self.poses, **coord)

        elif strategy == 'direct':
            position = {'x': target[0], 'y': target[1], 'z': target[2]}
            self.poses = instrument._move(self.poses, **position)
        else:
            raise RuntimeError('Unknown move strategy: {}'.format(strategy))
def well_vector(location):
    return unpack_location(location)