|
1 | 1 | from abc import ABCMeta, abstractmethod |
2 | | -from typing import Union |
| 2 | +from dataclasses import dataclass |
| 3 | +from typing import Optional, Union |
3 | 4 |
|
4 | 5 | from pylabrobot.arms.coords import CartesianCoords, JointCoords |
5 | 6 | from pylabrobot.machines.backend import MachineBackend |
6 | 7 |
|
7 | 8 |
|
| 9 | +@dataclass |
| 10 | +class VerticalAccess: |
| 11 | + """Access location from above (most common pattern for stacks and tube racks). |
| 12 | +
|
| 13 | + This access pattern is used when approaching a location from above, such as |
| 14 | + picking from a plate stack or tube rack on the deck. |
| 15 | +
|
| 16 | + Args: |
| 17 | + approach_height_mm: Height above the target position to move to before |
| 18 | + descending to grip (default: 100mm) |
| 19 | + clearance_mm: Vertical distance to retract after gripping before lateral |
| 20 | + movement (default: 100mm) |
| 21 | + gripper_offset_mm: Additional vertical offset added when holding a plate, |
| 22 | + accounts for gripper thickness (default: 10mm) |
| 23 | + """ |
| 24 | + approach_height_mm: float = 100 |
| 25 | + clearance_mm: float = 100 |
| 26 | + gripper_offset_mm: float = 10 |
| 27 | + |
| 28 | + |
| 29 | +@dataclass |
| 30 | +class HorizontalAccess: |
| 31 | + """Access location from the side (for hotel-style plate carriers). |
| 32 | +
|
| 33 | + This access pattern is used when approaching a location horizontally, such as |
| 34 | + accessing plates in a hotel-style storage system. |
| 35 | +
|
| 36 | + Args: |
| 37 | + approach_distance_mm: Horizontal distance in front of the target to stop |
| 38 | + before moving in to grip (default: 50mm) |
| 39 | + clearance_mm: Horizontal distance to retract after gripping before lifting |
| 40 | + (default: 50mm) |
| 41 | + lift_height_mm: Vertical distance to lift the plate after horizontal retract, |
| 42 | + before lateral movement (default: 100mm) |
| 43 | + gripper_offset_mm: Additional vertical offset added when holding a plate, |
| 44 | + accounts for gripper thickness (default: 10mm) |
| 45 | + """ |
| 46 | + approach_distance_mm: float = 50 |
| 47 | + clearance_mm: float = 50 |
| 48 | + lift_height_mm: float = 100 |
| 49 | + gripper_offset_mm: float = 10 |
| 50 | + |
| 51 | + |
| 52 | +AccessPattern = Union[VerticalAccess, HorizontalAccess] |
| 53 | + |
| 54 | + |
8 | 55 | class ArmBackend(MachineBackend, metaclass=ABCMeta): |
9 | 56 | """Backend for a robotic arm""" |
10 | 57 |
|
@@ -49,20 +96,48 @@ async def move_to_safe(self): |
49 | 96 | ... |
50 | 97 |
|
51 | 98 | @abstractmethod |
52 | | - async def approach(self, position: Union[CartesianCoords, JointCoords], approach_height: float): |
53 | | - """Move the arm to a position above the specified coordinates by a certain distance.""" |
| 99 | + async def approach( |
| 100 | + self, |
| 101 | + position: Union[CartesianCoords, JointCoords], |
| 102 | + access: Optional[AccessPattern] = None |
| 103 | + ): |
| 104 | + """Move the arm to an approach position (offset from target). |
| 105 | +
|
| 106 | + Args: |
| 107 | + position: Target position (CartesianCoords or JointCoords) |
| 108 | + access: Access pattern defining how to approach the target. |
| 109 | + Defaults to VerticalAccess() if not specified. |
| 110 | + """ |
54 | 111 | ... |
55 | 112 |
|
56 | 113 | @abstractmethod |
57 | | - async def pick_plate(self, position: Union[CartesianCoords, JointCoords], approach_height: float): |
58 | | - """Pick a plate from the specified position.""" |
| 114 | + async def pick_plate( |
| 115 | + self, |
| 116 | + position: Union[CartesianCoords, JointCoords], |
| 117 | + access: Optional[AccessPattern] = None |
| 118 | + ): |
| 119 | + """Pick a plate from the specified position. |
| 120 | +
|
| 121 | + Args: |
| 122 | + position: Target position for pickup |
| 123 | + access: Access pattern defining how to approach and retract. |
| 124 | + Defaults to VerticalAccess() if not specified. |
| 125 | + """ |
59 | 126 | ... |
60 | 127 |
|
61 | 128 | @abstractmethod |
62 | 129 | async def place_plate( |
63 | | - self, position: Union[CartesianCoords, JointCoords], approach_height: float |
| 130 | + self, |
| 131 | + position: Union[CartesianCoords, JointCoords], |
| 132 | + access: Optional[AccessPattern] = None |
64 | 133 | ): |
65 | | - """Place a plate at the specified position.""" |
| 134 | + """Place a plate at the specified position. |
| 135 | +
|
| 136 | + Args: |
| 137 | + position: Target position for placement |
| 138 | + access: Access pattern defining how to approach and retract. |
| 139 | + Defaults to VerticalAccess() if not specified. |
| 140 | + """ |
66 | 141 | ... |
67 | 142 |
|
68 | 143 | @abstractmethod |
|
0 commit comments