Skip to content

Commit 52f5e68

Browse files
rickwierengaclaude
andauthored
Replace PreciseFlexJointCoords with PFAxis IntEnum + dict (#901)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 79ffe09 commit 52f5e68

7 files changed

Lines changed: 220 additions & 272 deletions

File tree

docs/user_guide/01_material-handling/arms/c_scara/precise-flex-pf400/hello-world.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"from pylabrobot.arms.precise_flex.pf_400 import PreciseFlex400Backend\n",
3333
"\n",
3434
"from pylabrobot.arms.precise_flex.coords import PreciseFlexCartesianCoords\n",
35-
"from pylabrobot.arms.precise_flex.joints import PreciseFlexJointCoords\n",
35+
"from pylabrobot.arms.precise_flex.joints import PFAxis\n",
3636
"from pylabrobot.resources import Coordinate, Rotation"
3737
]
3838
},
@@ -144,14 +144,14 @@
144144
"metadata": {},
145145
"outputs": [],
146146
"source": [
147-
"location = PreciseFlexJointCoords(\n",
148-
" base=99.981,\n",
149-
" shoulder=-36.206,\n",
150-
" elbow=83.063,\n",
151-
" wrist=-331.7,\n",
152-
" gripper=126.084,\n",
153-
" rail=0.0\n",
154-
")\n",
147+
"location = {\n",
148+
" PFAxis.BASE: 99.981,\n",
149+
" PFAxis.SHOULDER: -36.206,\n",
150+
" PFAxis.ELBOW: 83.063,\n",
151+
" PFAxis.WRIST: -331.7,\n",
152+
" PFAxis.GRIPPER: 126.084,\n",
153+
" PFAxis.RAIL: 0.0,\n",
154+
"}\n",
155155
"await arm.move_to(location)"
156156
]
157157
},

pylabrobot/arms/backend.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from abc import ABCMeta, abstractmethod
22
from dataclasses import dataclass
3-
from typing import Optional, Union
3+
from typing import Dict, Optional, Union
44

55
from pylabrobot.arms.precise_flex.coords import PreciseFlexCartesianCoords
6-
from pylabrobot.arms.standard import JointCoords
76
from pylabrobot.machines.backend import MachineBackend
87

98

@@ -78,20 +77,20 @@ async def move_to_safe(self) -> None:
7877
@abstractmethod
7978
async def approach(
8079
self,
81-
position: Union[PreciseFlexCartesianCoords, JointCoords],
80+
position: Union[PreciseFlexCartesianCoords, Dict[int, float]],
8281
access: Optional[AccessPattern] = None,
8382
) -> None:
8483
"""Move the arm to an approach position (offset from target).
8584
8685
Args:
87-
position: Target position (CartesianCoords or JointCoords)
86+
position: Target position (CartesianCoords or joint position dict)
8887
access: Access pattern defining how to approach the target. Defaults to VerticalAccess() if not specified.
8988
"""
9089

9190
@abstractmethod
9291
async def pick_up_resource(
9392
self,
94-
position: Union[PreciseFlexCartesianCoords, JointCoords],
93+
position: Union[PreciseFlexCartesianCoords, Dict[int, float]],
9594
plate_width: float,
9695
access: Optional[AccessPattern] = None,
9796
) -> None:
@@ -105,7 +104,7 @@ async def pick_up_resource(
105104
@abstractmethod
106105
async def drop_resource(
107106
self,
108-
position: Union[PreciseFlexCartesianCoords, JointCoords],
107+
position: Union[PreciseFlexCartesianCoords, Dict[int, float]],
109108
access: Optional[AccessPattern] = None,
110109
) -> None:
111110
"""Place a plate at the specified position.
@@ -116,11 +115,11 @@ async def drop_resource(
116115
"""
117116

118117
@abstractmethod
119-
async def move_to(self, position: Union[PreciseFlexCartesianCoords, JointCoords]) -> None:
118+
async def move_to(self, position: Union[PreciseFlexCartesianCoords, Dict[int, float]]) -> None:
120119
"""Move the arm to a specified position in 3D space or in joint space."""
121120

122121
@abstractmethod
123-
async def get_joint_position(self) -> JointCoords:
122+
async def get_joint_position(self) -> Dict[int, float]:
124123
"""Get the current position of the arm in joint space."""
125124

126125
@abstractmethod
Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
1-
from dataclasses import dataclass
2-
from typing import Iterator
1+
from enum import IntEnum
32

43

5-
@dataclass
6-
class PreciseFlexJointCoords:
7-
base: float
8-
shoulder: float
9-
elbow: float
10-
wrist: float
11-
gripper: float
12-
rail: float = 0
13-
14-
def __iter__(self) -> Iterator[float]:
15-
return iter(
16-
[
17-
self.rail,
18-
self.base,
19-
self.shoulder,
20-
self.elbow,
21-
self.wrist,
22-
self.gripper,
23-
]
24-
)
4+
class PFAxis(IntEnum):
5+
BASE = 1
6+
SHOULDER = 2
7+
ELBOW = 3
8+
WRIST = 4
9+
GRIPPER = 5
10+
RAIL = 6

0 commit comments

Comments
 (0)