Skip to content

Commit a332ab5

Browse files
miikeeclaude
andcommitted
Fix PreciseFlex orientation mapping and wrist constraints
- Fix elbow orientation int<->enum mapping (1=RIGHT, 2=LEFT per GPL spec) - Add GPL_Single flag (0x1000) to restrict wrist to ±180° range - Fix rotation.y typo to rotation.roll in set_location_xyz - Fix attach() call to pass robot index parameter 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 326dabc commit a332ab5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pylabrobot/arms/precise_flex/precise_flex_backend.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async def setup(self):
9191
await self.io.setup()
9292
await self.set_mode("pc")
9393
await self.power_on_robot()
94-
await self.attach()
94+
await self.attach(1)
9595

9696
async def stop(self):
9797
"""Stop the PreciseFlex backend."""
@@ -141,16 +141,16 @@ async def move_to_safe(self) -> None:
141141

142142
def _convert_orientation_int_to_enum(self, orientation_int: int) -> Optional[ElbowOrientation]:
143143
if orientation_int == 1:
144-
return ElbowOrientation.LEFT
145-
if orientation_int == 2:
146144
return ElbowOrientation.RIGHT
145+
if orientation_int == 2:
146+
return ElbowOrientation.LEFT
147147
return None
148148

149149
def _convert_orientation_enum_to_int(self, orientation: Optional[ElbowOrientation]) -> int:
150150
if orientation == ElbowOrientation.LEFT:
151-
return 1
152-
if orientation == ElbowOrientation.RIGHT:
153151
return 2
152+
if orientation == ElbowOrientation.RIGHT:
153+
return 1
154154
return 0
155155

156156
async def home_all(self) -> None:
@@ -462,6 +462,7 @@ async def _pick_plate_c(
462462
await self.set_location_xyz(self.location_index, cartesian_position)
463463
await self._set_grip_detail(access)
464464
orientation_int = self._convert_orientation_enum_to_int(cartesian_position.orientation)
465+
orientation_int |= 0x1000 # GPL_Single: restrict wrist to ±180°
465466
await self.set_location_config(self.location_index, orientation_int)
466467
await self.pick_plate_from_stored_position(
467468
self.location_index, self.horizontal_compliance, self.horizontal_compliance_torque
@@ -476,6 +477,7 @@ async def _place_plate_c(
476477
await self.set_location_xyz(self.location_index, cartesian_position)
477478
await self._set_grip_detail(access)
478479
orientation_int = self._convert_orientation_enum_to_int(cartesian_position.orientation)
480+
orientation_int |= 0x1000 # GPL_Single: restrict wrist to ±180°
479481
await self.set_location_config(self.location_index, orientation_int)
480482
await self.place_plate_to_stored_position(
481483
self.location_index, self.horizontal_compliance, self.horizontal_compliance_torque
@@ -985,7 +987,7 @@ async def set_location_xyz(
985987
f"{cartesian_position.location.z} "
986988
f"{cartesian_position.rotation.yaw} "
987989
f"{cartesian_position.rotation.pitch} "
988-
f"{cartesian_position.rotation.y}"
990+
f"{cartesian_position.rotation.roll}"
989991
)
990992

991993
async def get_location_z_clearance(self, location_index: int) -> tuple[int, float, bool]:
@@ -1587,6 +1589,7 @@ async def move_c(
15871589

15881590
if cartesian_coords.orientation is not None:
15891591
config_int = self._convert_orientation_enum_to_int(cartesian_coords.orientation)
1592+
config_int |= 0x1000 # GPL_Single: restrict wrist to ±180°
15901593
cmd += f"{config_int}"
15911594

15921595
await self.send_command(cmd)

0 commit comments

Comments
 (0)