|
| 1 | +import asyncio |
| 2 | +import argparse |
| 3 | +from pylabrobot.liquid_handling import LiquidHandler, STARBackend |
| 4 | +from pylabrobot.liquid_handling.standard import GripDirection |
| 5 | +from pylabrobot.resources import CellVis_96_wellplate_350uL_Fb, PLT_CAR_L5AC_A00, STARLetDeck, STARDeck, Plate, PlateCarrier |
| 6 | + |
| 7 | + |
| 8 | +async def qc_iswap(lh: LiquidHandler, backend: STARBackend, plate: Plate, plate_carrier: PlateCarrier): |
| 9 | + async def move_plate(pickup_direction: GripDirection, drop_direction: GripDirection, destination): |
| 10 | + await lh.pick_up_resource( |
| 11 | + plate, |
| 12 | + direction=pickup_direction, |
| 13 | + pickup_distance_from_top=6, |
| 14 | + iswap_fold_up_sequence_at_the_end_of_process=False, |
| 15 | + ) |
| 16 | + await lh.drop_resource( |
| 17 | + destination, |
| 18 | + direction=drop_direction, |
| 19 | + ) |
| 20 | + |
| 21 | + async def in_place_tests(spot): |
| 22 | + print(f"performing in-place tests on spot {spot}") |
| 23 | + |
| 24 | + # move in place left and right |
| 25 | + print(" testing iswap left and right movement...") |
| 26 | + await move_plate(GripDirection.LEFT, GripDirection.LEFT, plate_carrier[spot]) |
| 27 | + |
| 28 | + await move_plate(GripDirection.RIGHT, GripDirection.RIGHT, plate_carrier[spot]) |
| 29 | + print(" [pass] iswap left and right movement successful") |
| 30 | + |
| 31 | + # move and rotate 180 |
| 32 | + print(" testing iswap left and right movement with 180 degree rotation...") |
| 33 | + await move_plate(GripDirection.RIGHT, GripDirection.LEFT, plate_carrier[spot]) |
| 34 | + await move_plate(GripDirection.LEFT, GripDirection.RIGHT, plate_carrier[spot]) |
| 35 | + print(" [pass] iswap left and right movement with 180 degree rotation successful") |
| 36 | + |
| 37 | + print(f"[pass] in-place tests on spot {spot} successful") |
| 38 | + |
| 39 | + await in_place_tests(0) # test on the first spot |
| 40 | + print("moving plate to fifth spot...") |
| 41 | + |
| 42 | + await move_plate(GripDirection.LEFT, GripDirection.LEFT, plate_carrier[4]) # move to the fifth spot |
| 43 | + await in_place_tests(4) # test on the fifth spot |
| 44 | + await move_plate(GripDirection.LEFT, GripDirection.LEFT, plate_carrier[0]) # move back to the first spot |
| 45 | + |
| 46 | + print("parking iswap...") |
| 47 | + await backend.park_iswap() |
| 48 | + |
| 49 | + |
| 50 | +async def main(lh: LiquidHandler, backend: STARBackend, plate: Plate, plate_carrier: PlateCarrier): |
| 51 | + print("Starting QC for Hamilton STAR(let)") |
| 52 | + |
| 53 | + await lh.setup() |
| 54 | + print("[pass] setup successful") |
| 55 | + |
| 56 | + validate_iswap = True |
| 57 | + if validate_iswap: |
| 58 | + try: |
| 59 | + if not backend.iswap_installed: |
| 60 | + raise RuntimeError("iswap is not installed on the backend, cannot run iswap QC test.") |
| 61 | + await qc_iswap(lh, backend, plate, plate_carrier) |
| 62 | + print("[pass] iswap QC test completed successfully") |
| 63 | + except Exception as e: |
| 64 | + print(f"[fail] iswap QC test failed: {e}") |
| 65 | + # move robot to safe position |
| 66 | + await backend.park_iswap() |
| 67 | + raise |
| 68 | + |
| 69 | + await lh.stop() |
| 70 | + print("All QC tests completed successfully") |
| 71 | + |
| 72 | + |
| 73 | +if __name__ == "__main__": |
| 74 | + parser = argparse.ArgumentParser(description="QC Hamilton STAR(let)") |
| 75 | + parser.add_argument("--model", choices=["STAR", "STARlet"], default="STAR", help="Model to use") |
| 76 | + parser.add_argument("--plate-carrier-rails", type=int, default=6, help="Rails where the plate carrier is placed") |
| 77 | + args = parser.parse_args() |
| 78 | + |
| 79 | + assert args.plate_carrier_rails >= 6, "will crash into robot frame" |
| 80 | + |
| 81 | + backend = STARBackend() |
| 82 | + lh = LiquidHandler(backend=backend, deck=STARDeck() if args.model == "STAR" else STARLetDeck()) |
| 83 | + plate_carrier = PLT_CAR_L5AC_A00(name="plate_carrier") |
| 84 | + plate_carrier[0] = plate = CellVis_96_wellplate_350uL_Fb(name="plate") |
| 85 | + lh.deck.assign_child_resource(plate_carrier, rails=args.plate_carrier_rails) |
| 86 | + |
| 87 | + asyncio.run(main(lh, backend, plate, plate_carrier)) |
0 commit comments