11from abc import ABCMeta , abstractmethod
22from enum import Enum
3+ from dataclasses import dataclass
34
45from pylabrobot .machines .backend import MachineBackend
56
67class ElbowOrientation (Enum ):
7- LEFT = "left"
88 RIGHT = "right"
9+ LEFT = "left"
10+
11+ @dataclass
12+ class JointCoords :
13+ rail : float
14+ base : float
15+ shoulder : float
16+ elbow : float
17+ wrist : float
18+ gripper : float
19+
20+ @dataclass
21+ class CartesianCoords :
22+ x : float
23+ y : float
24+ z : float
25+ yaw : float
26+ pitch : float
27+ roll : float
28+ orientation : ElbowOrientation | None = None
929
1030class ArmBackend (MachineBackend , metaclass = ABCMeta ):
1131 """Backend for a robotic arm"""
@@ -51,51 +71,31 @@ async def move_to_safe(self):
5171 ...
5272
5373 @abstractmethod
54- async def approach_j (self , joint_position : tuple [ float , float , float , float , float , float , float ] , approach_height : float ):
74+ async def approach (self , position : CartesianCoords | JointCoords , approach_height : float ):
5575 """Move the arm to a position above the specified coordinates by a certain distance."""
5676 ...
5777
5878 @abstractmethod
59- async def pick_plate_j (self , joint_position : tuple [ float , float , float , float , float , float , float ] , approach_height : float ):
79+ async def pick_plate (self , position : CartesianCoords | JointCoords , approach_height : float ):
6080 """Pick a plate from the specified position."""
6181 ...
6282
6383 @abstractmethod
64- async def place_plate_j (self , joint_position : tuple [ float , float , float , float , float , float , float ] , approach_height : float ):
84+ async def place_plate (self , position : CartesianCoords | JointCoords , approach_height : float ):
6585 """Place a plate at the specified position."""
6686 ...
6787
6888 @abstractmethod
69- async def move_to_j (self , joint_position : tuple [ float , float , float , float , float , float , float ] ):
89+ async def move_to (self , position : CartesianCoords | JointCoords ):
7090 """Move the arm to a specified position in 3D space."""
7191 ...
7292
7393 @abstractmethod
74- async def get_position_j (self ) -> tuple [ float , float , float , float , float , float , float ] :
94+ async def get_joint_position (self ) -> JointCoords :
7595 """Get the current position of the arm in 3D space."""
7696 ...
7797
7898 @abstractmethod
79- async def approach_c (self , cartesian_position : tuple [float , float , float , float , float , float ], approach_height : float , orientation : ElbowOrientation | None = None ):
80- """Move the arm to a position above the specified coordinates by a certain distance."""
81- ...
82-
83- @abstractmethod
84- async def pick_plate_c (self , cartesian_position : tuple [float , float , float , float , float , float ], approach_height : float , orientation : ElbowOrientation | None = None ):
85- """Pick a plate from the specified position."""
86- ...
87-
88- @abstractmethod
89- async def place_plate_c (self , cartesian_position : tuple [float , float , float , float , float , float ], approach_height : float , orientation : ElbowOrientation | None = None ):
90- """Place a plate at the specified position."""
91- ...
92-
93- @abstractmethod
94- async def move_to_c (self , cartesian_position : tuple [float , float , float , float , float , float ], orientation : ElbowOrientation | None = None ):
95- """Move the arm to a specified position in 3D space."""
96- ...
97-
98- @abstractmethod
99- async def get_position_c (self ) -> tuple [float , float , float , float , float , float , ElbowOrientation | None ]:
99+ async def get_cartesian_position (self ) -> CartesianCoords :
100100 """Get the current position of the arm in 3D space."""
101101 ...
0 commit comments