Skip to content

Commit 2fefadb

Browse files
authored
Fix request_iswap_rotation_drive_orientation (#669)
1 parent 363effa commit 2fefadb

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

pylabrobot/liquid_handling/backends/hamilton/STAR_backend.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6766,8 +6766,8 @@ async def iswap_put_plate(
67666766

67676767
async def request_iswap_rotation_drive_position_increments(self) -> int:
67686768
"""Query the iSWAP rotation drive position (units: increments) from the firmware."""
6769-
response = await self.send_command(module="R0", command="RS", fmt="rs######")
6770-
return cast(int, response["rs"])
6769+
response = await self.send_command(module="R0", command="RW", fmt="rw######")
6770+
return cast(int, response["rw"])
67716771

67726772
async def request_iswap_rotation_drive_orientation(self) -> "RotationDriveOrientation":
67736773
"""
@@ -6787,6 +6787,8 @@ async def request_iswap_rotation_drive_orientation(self) -> "RotationDriveOrient
67876787
STARBackend.RotationDriveOrientation.FRONT: range(-75, 26),
67886788
STARBackend.RotationDriveOrientation.RIGHT: range(29018, 29119),
67896789
STARBackend.RotationDriveOrientation.LEFT: range(-29166, -29065),
6790+
STARBackend.RotationDriveOrientation.PARKED_RIGHT: range(29450, 29550),
6791+
# TODO: add range for STAR(let)s with "PARKED_LEFT" setting
67906792
}
67916793

67926794
motor_position_increments = await self.request_iswap_rotation_drive_position_increments()
@@ -6797,7 +6799,7 @@ async def request_iswap_rotation_drive_orientation(self) -> "RotationDriveOrient
67976799

67986800
raise ValueError(
67996801
f"Unknown rotation orientation: {motor_position_increments}. "
6800-
f"Expected one of {list(rotation_orientation_to_motor_increment_dict)}."
6802+
f"Expected one of {list(rotation_orientation_to_motor_increment_dict.values())}."
68016803
)
68026804

68036805
async def request_iswap_wrist_drive_position_increments(self) -> int:
@@ -6879,7 +6881,7 @@ async def iswap_rotate(
68796881
elif rotation_drive == STARBackend.RotationDriveOrientation.RIGHT:
68806882
position += 30
68816883
else:
6882-
raise ValueError("Invalid rotation drive orientation")
6884+
raise ValueError(f"Invalid rotation drive orientation: {rotation_drive}")
68836885

68846886
if grip_direction == GripDirection.FRONT:
68856887
position += 1
@@ -7567,14 +7569,22 @@ class RotationDriveOrientation(enum.Enum):
75677569
LEFT = 1
75687570
FRONT = 2
75697571
RIGHT = 3
7572+
PARKED_RIGHT = None
75707573

75717574
async def rotate_iswap_rotation_drive(self, orientation: RotationDriveOrientation):
7572-
return await self.send_command(
7573-
module="R0",
7574-
command="WP",
7575-
auto_id=False,
7576-
wp=orientation.value,
7577-
)
7575+
if orientation in {
7576+
STARBackend.RotationDriveOrientation.RIGHT,
7577+
STARBackend.RotationDriveOrientation.FRONT,
7578+
STARBackend.RotationDriveOrientation.LEFT,
7579+
}:
7580+
return await self.send_command(
7581+
module="R0",
7582+
command="WP",
7583+
auto_id=False,
7584+
wp=orientation.value,
7585+
)
7586+
else:
7587+
raise ValueError(f"Invalid rotation drive orientation: {orientation}")
75787588

75797589
class WristDriveOrientation(enum.Enum):
75807590
RIGHT = 1

0 commit comments

Comments
 (0)