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))
示例#2
0
    def add_container_to_pose_tracker(self, location, container: Container):
        """
        Add container and child wells to pose tracker. Sets container.parent
        (slot) as pose tracker parent
        """
        self.poses = pose_tracker.add(
            self.poses,
            container,
            container.parent,
            pose_tracker.Point(*container._coordinates))

        for well in container:
            center_x, center_y, center_z = well.top()[1]
            offset_x, offset_y, offset_z = well._coordinates
            center_z = 0
            self.poses = pose_tracker.add(
                self.poses,
                well,
                container,
                pose_tracker.Point(
                    center_x + offset_x,
                    center_y + offset_y,
                    center_z + offset_z
                )
            )
示例#3
0
    def setup_deck(self):
        self.add_slots_to_deck()

        # Setup Deck as root object for pose tracker
        self.poses = pose_tracker.add(
            self.poses,
            self._deck
        )

        for slot in self._deck:
            self.poses = pose_tracker.add(
                self.poses,
                slot,
                self._deck,
                pose_tracker.Point(*slot._coordinates)
            )

        # @TODO (Laura & Andy) Slot and type of trash
        # needs to be pulled from config file
        if fflags.short_fixed_trash():
            self._fixed_trash = self.add_container(
                'opentrons_1_trash_850ml_fixed', '12')
        else:
            self._fixed_trash = self.add_container(
                'opentrons_1_trash_1100ml_fixed', '12')
示例#4
0
    def add_instrument(self, mount, instrument):
        """
        Adds instrument to a robot.

        Parameters
        ----------
        mount : str
            Specifies which axis the instruments is attached to.
            Valid options are "left" or "right".
        instrument : Instrument
            An instance of a :class:`Pipette` to attached to the axis.

        Notes
        -----
        A canonical way to add to add a Pipette to a robot is:

        ::

            from opentrons import instruments
            m300 = instruments.P300_Multi(mount='left')

        This will create a pipette and call :func:`add_instrument`
        to attach the instrument.
        """
        if mount in self._instruments:
            prev_instr = self._instruments[mount]
            raise RuntimeError('Instrument {0} already on {1} mount'.format(
                prev_instr.name, mount))
        self._instruments[mount] = instrument

        instrument.instrument_actuator = self._actuators[mount]['plunger']
        instrument.instrument_mover = self._actuators[mount]['carriage']

        # instrument_offset is the distance found (with tip-probe) between
        # the pipette's expected position, and the actual position
        # this is expected to be no greater than ~3mm
        # Z is not included, because Z offsets found during tip-probe are used
        # to determined the tip's length
        cx, cy, _ = self.config.instrument_offset[mount][instrument.type]

        # model_offset is the expected position of the pipette, determined
        # by designed dimensions of that model (eg: p10-multi vs p300-single)
        mx, my, mz = instrument.model_offset

        # combine each offset to get the pipette's position relative to gantry
        _x, _y, _z = (mx + cx, my + cy, mz)
        # if it's the left mount, apply the offset from right pipette
        if mount == 'left':
            _x, _y, _z = (_x + self.config.mount_offset[0],
                          _y + self.config.mount_offset[1],
                          _z + self.config.mount_offset[2])
        self.poses = pose_tracker.add(self.poses,
                                      instrument,
                                      parent=mount,
                                      point=(_x, _y, _z))