Skip to content

Commit 37c2f2a

Browse files
committed
Edit zero_torque and set_pallet_index commands; WIP editting pallet configuration tests
1 parent 7a7a06e commit 37c2f2a

File tree

2 files changed

+175
-177
lines changed

2 files changed

+175
-177
lines changed

pylabrobot/arms/precise_flex/precise_flex_api.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ async def wait_for_eom(self) -> None:
11801180

11811181

11821182

1183-
async def zero_torque(self, enable: bool, axis_mask: int = 0) -> None:
1183+
async def zero_torque(self, enable: bool, axis_mask: int = 1) -> None:
11841184
"""Sets or clears zero torque mode for the selected robot.
11851185
11861186
Individual axes may be placed into zero torque mode while the remaining axes are servoing.
@@ -1193,8 +1193,12 @@ async def zero_torque(self, enable: bool, axis_mask: int = 0) -> None:
11931193
1 = axis 1, 2 = axis 2, 4 = axis 3, 8 = axis 4, etc.
11941194
Ignored when enable is False.
11951195
"""
1196-
enable_value = 1 if enable else 0
1197-
await self.send_command(f"zeroTorque {enable_value} {axis_mask}")
1196+
1197+
if enable:
1198+
assert axis_mask > 0, "axis_mask must be greater than 0"
1199+
await self.send_command(f"zeroTorque 1 {axis_mask}")
1200+
else:
1201+
await self.send_command(f"zeroTorque 0")
11981202

11991203

12001204

@@ -1361,8 +1365,8 @@ async def get_pallet_index(self, station_id: int) -> tuple[int, int, int, int]:
13611365

13621366
return (station_id, pallet_index_x, pallet_index_y, pallet_index_z)
13631367

1364-
async def set_pallet_index(self, station_id: int, pallet_index_x: int | None = None,
1365-
pallet_index_y: int | None = None, pallet_index_z: int | None = None) -> None:
1368+
async def set_pallet_index(self, station_id: int, pallet_index_x: int = 0,
1369+
pallet_index_y: int = 0, pallet_index_z: int = 0) -> None:
13661370
"""Set the pallet index value from 1 to n of the station used by subsequent pick or place.
13671371
13681372
If an index argument is 0 or omitted, the corresponding index is not changed.
@@ -1377,31 +1381,14 @@ async def set_pallet_index(self, station_id: int, pallet_index_x: int | None = N
13771381
Raises:
13781382
ValueError: If any index value is negative.
13791383
"""
1380-
if pallet_index_x is not None and pallet_index_x < 0:
1384+
if pallet_index_x < 0:
13811385
raise ValueError("Pallet index X cannot be negative")
1382-
if pallet_index_y is not None and pallet_index_y < 0:
1386+
if pallet_index_y < 0:
13831387
raise ValueError("Pallet index Y cannot be negative")
1384-
if pallet_index_z is not None and pallet_index_z < 0:
1388+
if pallet_index_z < 0:
13851389
raise ValueError("Pallet index Z cannot be negative")
13861390

1387-
command_parts = [f"PalletIndex {station_id}"]
1388-
1389-
if pallet_index_x is not None:
1390-
command_parts.append(str(pallet_index_x))
1391-
else:
1392-
command_parts.append("0")
1393-
1394-
if pallet_index_y is not None:
1395-
command_parts.append(str(pallet_index_y))
1396-
else:
1397-
command_parts.append("0")
1398-
1399-
if pallet_index_z is not None:
1400-
command_parts.append(str(pallet_index_z))
1401-
else:
1402-
command_parts.append("0")
1403-
1404-
await self.send_command(" ".join(command_parts))
1391+
await self.send_command(f"PalletIndex {station_id} {pallet_index_x} {pallet_index_y} {pallet_index_z}")
14051392

14061393
async def get_pallet_origin(self, station_id: int) -> tuple[int, float, float, float, float, float, float, int]:
14071394
"""Get the current pallet origin data for the specified station.

0 commit comments

Comments
 (0)