def calibrate_container_with_delta(pose_tree, container, delta_x, delta_y, delta_z, save, new_container_name=None): delta = Point(delta_x, delta_y, delta_z) new_coordinates = change_base( pose_tree, src=container, dst=container.parent) + delta pose_tree = update(pose_tree, container, new_coordinates) if ff.split_labware_definitions(): for well in container.wells(): well._coordinates = well._coordinates + delta else: container._coordinates = container._coordinates + delta if save and new_container_name: database.save_new_container(container, new_container_name) elif save: database.overwrite_container(container) return pose_tree
def update_pose_from_driver(self, pose_tree): # map from driver axis names to xyz and expand position # into point object point = Point( x=self._driver.position.get(self._axis_mapping.get('x', ''), 0.0), y=self._driver.position.get(self._axis_mapping.get('y', ''), 0.0), z=self._driver.position.get(self._axis_mapping.get('z', ''), 0.0) ) log.debug(f'Point in update pose from driver {point}') return update(pose_tree, self, point)
def update_config(self, **kwargs): """ Replace configuration values. kwargs should contain configuration keys. For instance: `robot.update_config(name='Grace Hopper')` will update the `name` key of the configuration. """ # Deck CLI tool needs to update the pose_tracker in real time to # successfully save tip probe center. Here, update the position # with freshly determined deck transform. if 'gantry_calibration' in kwargs: self.poses = pose_tracker.update(self.poses, self._gantry_cal_id, point=pose_tracker.Point(0, 0, 0), transform=array( kwargs['gantry_calibration'])) self.config = self.config._replace(**kwargs)
def _calibrate_container_with_delta(pose_tree, container, delta_x, delta_y, delta_z, save, new_container_name=None): delta = pose_tracker.Point(delta_x, delta_y, delta_z) # Note: pose tree is updated here, in order to update in-memory state. # Separately from that, on-disk state is updated. This is a point of # possible dis-unity. Would probably work better to un-load the labware # after calibration, and then reload it (would have to figure out where # in the call-stack this could be done without raising exceptions due # to trying to access old references). # Have to update all of the things in the pose tree that have the same # load name, otherwise you end up getting the calibration values # added together in the on-disk representation target_name = container.get_name() matching_entries = [ x for x in list(pose_tree.keys()) if type(x) == Container and x.get_name() == target_name ] for entry in matching_entries: old_coordinates = pose_tracker.change_base(pose_tree, src=entry, dst=entry.parent) new_coordinates = old_coordinates + delta pose_tree = pose_tracker.update(pose_tree, entry, new_coordinates) entry._coordinates = entry._coordinates + delta if save and container.properties.get('labware_hash'): save_new_offsets(container.properties['labware_hash'], delta, container.properties['definition']) elif save and new_container_name: database.save_new_container(container, new_container_name) elif save: database.overwrite_container(container) return pose_tree
def move(self, pose_tree, x=None, y=None, z=None, home_flagged_axes=True): """ Dispatch move command to the driver changing base of x, y and z from source coordinate system to destination. Value must be set for each axis that is mapped. home_flagged_axes: (default=True) This kwarg is passed to the driver. This ensures that any axes within this Mover's axis_mapping is homed before moving, if it has not yet done so. See driver docstring for details """ def defaults(_x, _y, _z): _x = _x if x is not None else 0 _y = _y if y is not None else 0 _z = _z if z is not None else 0 return _x, _y, _z dst_x, dst_y, dst_z = change_base( pose_tree, src=self._src, dst=self._dst, point=Point(*defaults(x, y, z))) driver_target = {} if 'x' in self._axis_mapping: assert x is not None, "Value must be set for each axis mapped" driver_target[self._axis_mapping['x']] = dst_x if 'y' in self._axis_mapping: assert y is not None, "Value must be set for each axis mapped" driver_target[self._axis_mapping['y']] = dst_y if 'z' in self._axis_mapping: assert z is not None, "Value must be set for each axis mapped" driver_target[self._axis_mapping['z']] = dst_z self._driver.move(driver_target, home_flagged_axes=home_flagged_axes) # Update pose with the new value. Since stepper motors are open loop # there is no need to to query diver for position return update(pose_tree, self, Point(*defaults(dst_x, dst_y, dst_z)))
def _calibrate_container_with_delta(pose_tree, container, delta_x, delta_y, delta_z, save, new_container_name=None): delta = pose_tracker.Point(delta_x, delta_y, delta_z) new_coordinates = pose_tracker.change_base( pose_tree, src=container, dst=container.parent) + delta pose_tree = pose_tracker.update(pose_tree, container, new_coordinates) container._coordinates = container._coordinates + delta if save and container.properties.get('labware_hash'): save_new_offsets(container.properties['labware_hash'], delta) elif save and new_container_name: database.save_new_container(container, new_container_name) elif save: database.overwrite_container(container) return pose_tree
def update_instrument_config(instrument, measured_center) -> Tuple[Point, float]: """ Update config and pose tree with instrument's x and y offsets and tip length based on delta between probe center and measured_center, persist updated config and return it """ from copy import deepcopy from opentrons.trackers.pose_tracker import update robot = instrument.robot config = robot.config instrument_offset = deepcopy(config.instrument_offset) dx, dy, dz = array(measured_center) - config.tip_probe.center log.debug("This is measured probe center dx {}".format(Point(dx, dy, dz))) # any Z offset will adjust the tip length, so instruments have Z=0 offset old_x, old_y, _ = instrument_offset[instrument.mount][instrument.type] instrument_offset[instrument.mount][instrument.type] = \ (old_x - dx, old_y - dy, 0.0) tip_length = deepcopy(config.tip_length) tip_length[instrument.model] = tip_length[instrument.model] + dz config = config \ ._replace(instrument_offset=instrument_offset) \ ._replace(tip_length=tip_length) robot.config = config log.debug("Updating config for {} instrument".format(instrument.mount)) robot_configs.save_robot_settings(config) new_coordinates = change_base( robot.poses, src=instrument, dst=instrument.instrument_mover) - Point( dx, dy, 0.0) robot.poses = update(robot.poses, instrument, new_coordinates) return robot.config
def test_update(state): state = update(state, '1-1', Point(0, 0, 0)) assert (change_base(state, src='1-1-1') == (1, 2, 3)).all()