Skip to content

Commit

Permalink
Partial tip changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos-fernandez committed Mar 4, 2024
1 parent 842ac6f commit 5567357
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 24 deletions.
32 changes: 25 additions & 7 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,7 @@ async def encoder_current_position_ot3(
self._encoder_position,
critical_point,
)
# print(f'api encoder_position: {self._encoder_position}')
return ot3pos

def _effector_pos_from_carriage_pos(
Expand Down Expand Up @@ -1196,7 +1197,6 @@ async def move_axes( # noqa: C901
await self.refresh_positions()

for axis in position.keys():
print(axis)
if not self._backend.axis_is_present(axis):
raise InvalidActuator(
message=f"{axis} is not present", detail={"axis": str(axis)}
Expand Down Expand Up @@ -2070,17 +2070,35 @@ async def verify_tip_presence(
async def _force_pick_up_tip(
self, mount: OT3Mount, pipette_spec: TipActionSpec
) -> Dict[Axis, float]:
for press in pipette_spec.tip_action_moves:
async with self._backend.motor_current(run_currents=press.currents):
press_moves = pipette_spec.tip_action_moves
press_dist = 0
for i in range(len(press_moves)):
async with self._backend.motor_current(run_currents=press_moves[i].currents):
target_down = target_position_from_relative(
mount, top_types.Point(z=press.distance), self._current_position
mount, top_types.Point(z=press_moves[i].distance), self._current_position
)
await self._move(target_down, speed=press.speed, expect_stalls=True)
press_dist = await self.encoder_current_position_ot3(mount)
if press.distance < 0:
await self._move(target_down, speed=press_moves[i].speed, expect_stalls=True)
await self._update_position_estimation([Axis.by_mount(mount)])
if i == 0:
await self._update_position_estimation([Axis.by_mount(mount)])
press_dist = await self.encoder_current_position_ot3(OT3Mount.LEFT)
if press_moves[i].distance < 0:
# we expect a stall has happened during a downward movement into the tiprack, so
# we want to update the motor estimation
await self._update_position_estimation([Axis.by_mount(mount)])
# for press in pipette_spec.tip_action_moves:
# async with self._backend.motor_current(run_currents=press.currents):
# target_down = target_position_from_relative(
# mount, top_types.Point(z=press.distance), self._current_position
# )
# await self._move(target_down, speed=press.speed, expect_stalls=True)
# if press.distance < 0:
# # we expect a stall has happened during a downward movement into the tiprack, so
# # we want to update the motor estimation
# await self._update_position_estimation([Axis.by_mount(mount)])
# press_dist = await self.encoder_current_position_ot3(mount, CriticalPoint.NOZZLE, True)
# print(f'Encoder Press Dist: {press_dist}')
# breakpoint()
return press_dist

async def _tip_motor_action(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@ async def jog(api, position, cp) -> Dict[Axis, float]:

elif input == "\r":
sys.stdout.flush()
position = await api.current_position_ot3(
mount, refresh=True, critical_point=cp
await api._update_position_estimation([Axis.by_mount(mount)])
position = await api.encoder_current_position_ot3(
mount, critical_point=cp, refresh=True
)
print("\r\n")
return position
position = await api.current_position_ot3(
mount, refresh=True, critical_point=cp
await api._update_position_estimation([Axis.by_mount(mount)])
position = await api.encoder_current_position_ot3(
mount, critical_point=cp, refresh = True
)

print(
Expand Down Expand Up @@ -276,8 +278,10 @@ async def calibrate_tiprack(api, home_position, mount):
tiprack_loc = Point(tiprack_loc[Axis.X],
tiprack_loc[Axis.Y],
tiprack_loc[Axis.by_mount(mount)])
await api.pick_up_tip(
mount, tip_length=tip_length[args.tip_size])
print(f'Befor Press Distance: {tiprack_loc[2]}')
press_dist = await api.pick_up_tip(
mount, tip_length=(tip_length[args.tip_size]-tip_overlap))
print(f'Press Distance:{press_dist}')
await api.home([Axis.Z_L])
cp = CriticalPoint.TIP
await asyncio.sleep(1)
Expand Down Expand Up @@ -373,21 +377,25 @@ async def _main() -> None:
await move_to_point(hw_api, mount, initial_dial_loc, cp)
current_position = await hw_api.current_position_ot3(mount, cp)
nozzle_loc = await jog(hw_api, current_position, cp)
number_of_channels = 96
number_of_channels = args.nozzles
nozzle_count = 0
x_offset = 0
y_offset = 0
measurements = []
num_of_columns = 12
measurement_map = {}
# num_of_columns = 12
num_of_columns = 1
for tip in range(1, number_of_channels + 1):
cp = CriticalPoint.NOZZLE
nozzle_count += 1
nozzle_position = Point(nozzle_loc[Axis.X] + x_offset,
# nozzle_position = Point(nozzle_loc[Axis.X] + x_offset,
nozzle_position = Point(nozzle_loc[Axis.X],
nozzle_loc[Axis.Y] + y_offset,
nozzle_loc[Axis.by_mount(mount)])
await move_to_point(hw_api, mount, nozzle_position, cp)
await asyncio.sleep(1)
nozzle_measurement = gauge.read()
measurement_map.update({nozzle_count: nozzle_measurement})
print("nozzle-",nozzle_count, "(mm): " , nozzle_measurement, end="")
print("\r", end="")
measurements.append(nozzle_measurement)
Expand All @@ -406,10 +414,10 @@ async def _main() -> None:
y_offset += 9
if nozzle_count % num_of_columns == 0:
x_offset = 0
print(f'Nozzle Measurements: {measurement_map}')
# Calibrate to tiprack
if (args.calibrate):
pickup_loc, droptip_loc = await calibrate_tiprack(hw_api, home_position, mount)
print(pickup_loc)
deck_slot['deck_slot'][args.tiprack_slot][Axis.X.name] = pickup_loc.x
deck_slot['deck_slot'][args.tiprack_slot][Axis.Y.name] = pickup_loc.y
deck_slot['deck_slot'][args.tiprack_slot]['Z'] = pickup_loc.z
Expand All @@ -420,18 +428,23 @@ async def _main() -> None:
home_w_tip = await hw_api.current_position_ot3(mount, cp)
# Calibrate Dial Indicator with single tip
if (args.calibrate):
nozzle_position
# cp = CriticalPoint.TIP
initial_dial_loc = Point(
deck_slot['deck_slot'][args.dial_slot]['X'],
deck_slot['deck_slot'][args.dial_slot]['Y'],
home_w_tip[Axis.by_mount(mount)])
# initial_dial_loc = Point(
# deck_slot['deck_slot'][args.dial_slot]['X'],
# deck_slot['deck_slot'][args.dial_slot]['Y'],
# home_w_tip[Axis.by_mount(mount)])
initial_dial_loc = Point(nozzle_loc[Axis.X],
nozzle_loc[Axis.Y],
nozzle_loc[Axis.by_mount(mount)])
print("Move to Dial Indicator")
await move_to_point(hw_api, mount, initial_dial_loc, cp)
current_position = await hw_api.current_position_ot3(mount, cp)
dial_loc = await jog(hw_api, current_position, cp)
dial_loc = Point(dial_loc[Axis.X],
dial_loc[Axis.Y],
dial_loc[Axis.by_mount(mount)])
await move_to_point()
deck_slot['deck_slot'][args.dial_slot][Axis.X.name] = dial_loc.x
deck_slot['deck_slot'][args.dial_slot][Axis.Y.name] = dial_loc.y
deck_slot['deck_slot'][args.dial_slot]['Z'] = dial_loc.z
Expand Down Expand Up @@ -538,10 +551,12 @@ async def _main() -> None:
pickup_loc[1] + row,
pickup_loc[2])
await move_to_point(hw_api, mount, pickup_loc, cp)
await hw_api.pick_up_tip(mount,
tip_length=tip_length[args.tip_size],
print(f'start_position{pickup_loc[2]}')
press_dist = await hw_api.pick_up_tip(mount,
tip_length=(tip_length[args.tip_size]-tip_overlap),
presses = 1,
increment = 0)
print(f'Press Distance: {press_dist}')
await hw_api.home_z(mount.LEFT)
cp = CriticalPoint.TIP
current_position = await hw_api.current_position_ot3(mount, cp)
Expand Down Expand Up @@ -577,7 +592,7 @@ async def _main() -> None:
parser.add_argument("--mount", type=str, choices=["left", "right"], default="left")
parser.add_argument("--tiprack_slot", type=str, choices=slot_locs, default="B2")
parser.add_argument("--dial_slot", type=str, choices=slot_locs, default="C2")
parser.add_argument("--trough_slot", type=str, choices=slot_locs, default="B3")
parser.add_argument("--trough_slot", type=str, choices=slot_locs, default="D1")
parser.add_argument("--dial_indicator", action="store_true")
parser.add_argument("--calibrate", action="store_true")
parser.add_argument("--measure_nozzles", action="store_true")
Expand Down Expand Up @@ -607,6 +622,7 @@ async def _main() -> None:
with open(path + cal_fn, 'r') as openfile:
deck_slot = json.load(openfile)
tip_length = {"T1K": 95.7, "T200": 58.35, "T50": 57.9}
tip_overlap = 10.5
if args.mount == "left":
mount = OT3Mount.LEFT
else:
Expand Down

0 comments on commit 5567357

Please sign in to comment.