Unify gripper API: move_gripper(width, force_sensing) + class hierarchy refactor#1044
Open
rickwierenga wants to merge 2 commits into
Open
Unify gripper API: move_gripper(width, force_sensing) + class hierarchy refactor#1044rickwierenga wants to merge 2 commits into
rickwierenga wants to merge 2 commits into
Conversation
79775e9 to
1fd90d8
Compare
…hy refactor
CanGrip backend mixin now exposes a single `move_gripper(width, force_sensing=False)`
plus required `min_gripper_width` / `max_gripper_width` (Optional[float]) properties,
replacing the old `open_gripper(gripper_width)` / `close_gripper(gripper_width)` pair.
Widths are always in mm; backends with non-mm hardware convert internally.
Frontend `open_gripper()` / `close_gripper()` are no-width wrappers that read
max/min from the backend and raise NotImplementedError when the corresponding
limit is None. They still accept `backend_params`.
Arm capability hierarchy split for clarity:
_BaseArm
└── GripperArm (abstract; owns gripper-width controls)
├── FixedAxisGripperArm (was GripperArm; grip_axis="x"|"y")
├── OrientableGripperArm (was OrientableArm)
└── ArticulatedGripperArm (was ArticulatedArm)
Concrete backends migrated:
- iSWAP: GF/GC commands now flow through move_gripper; CloseGripperParams
renamed to GripParams; min=50, max=145 mm (placeholders).
- CoreGripper: min=9, max=None (no commandable open width); ZO still fires
on move_gripper(_, force_sensing=False); force_sensing=True raises.
- PreciseFlex PF400: min=60, max=145 mm (placeholders); routes to
gripper 1 / gripper 2 firmware commands.
- xArm6: min/max_gripper_width delegate to existing gripper_min_mm/gripper_max_mm.
The legacy pylabrobot.arms shim package is deleted entirely.
Tests, notebooks, and the architecture / user-guide docs are updated to the
new API and class names.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…lers - Frontend GripperArm.move_gripper raises ValueError when width is outside the backend's advertised [min_gripper_width, max_gripper_width] (None bounds skip the check on that side). - iSWAP move_gripper raises ValueError when backend_params is passed with force_sensing=False (GripParams only applies to the GC branch). - PreciseFlex backend gains a required closed_gripper_position constructor param and a _mm_to_firmware_units helper; move_gripper now converts mm to firmware units (linear, slope 1) before issuing GripOpenPos / GripClosePos. - Fix xArm6 pick_up_at_joint_position calling the nonexistent close_gripper; rewrite stale tests (mm/unit defaults, removed kwarg). - Fix legacy STAR_backend.iswap_open_gripper and liquid_handler.py OrientableArm import / instantiation after the v1b1 renames. - Migrate pf400_test.ipynb and precise_flex/hello-world.ipynb to the new API; drop dead docs/api/pylabrobot.arms.rst; fix architecture.md, arms.md, hamilton.rst, iswap.ipynb references. - Add docstrings on frontend wrappers, abstract GripperArm, and CanGrip force_sensing contract; reword "interface compatibility" docstring framing. - Tests: new precise_flex_tests.py (move_gripper wire bytes + helper anchor), abstract GripperArm cannot be instantiated, iSWAP backend_params rejection, width-bounds validation on the frontend. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Collapses
open_gripper(width)/close_gripper(width)into a single backend primitivemove_gripper(width, force_sensing=False)and adds requiredmin_gripper_width/max_gripper_width(Optional[float]) properties onCanGrip. Widths are always in mm.Frontend
open_gripper()/close_gripper()become no-width wrappers that read max/min from the backend and raiseNotImplementedErrorwhen the corresponding limit isNone. They still acceptbackend_params.Splits the arm class hierarchy so
GripperArmis the abstract base that owns gripper-width controls, with three concrete subclasses:Concrete backends migrated:
move_gripper;CloseGripperParamsrenamed toGripParams; placeholdermin=50/max=145mm.min=9,max=None;move_gripper(_, force_sensing=False)still fires ZO, force-sensing raises.min=60/max=145mm; routes to firmwaregripper 1/gripper 2.min/max_gripper_widthdelegate to existinggripper_min_mm/gripper_max_mm.Deletes the legacy
pylabrobot.armsshim package entirely.Updates tests, notebooks, and architecture / user-guide docs.
Notes for review
GripOpenPos/GripClosePosfirmware commands may want aclosed_gripper_position-anchored mm→units helper (called out in theCanGripdocstring); current behaviour pass-through preserved.v1b1that this branch does not fix or worsen (test_custom_mm_per_gripper_unit,test_pick_up_at_joint_position,test_pick_up_at_location_move_then_close).Test plan
python -m pytest pylabrobot/capabilities/arms pylabrobot/hamilton/liquid_handlers/star/tests pylabrobot/ufactory/xarm6/backend_tests.py(58 pass; 3 pre-existing xArm6 failures unchanged)open_gripper()/close_gripper()/move_gripper(..., force_sensing=True, backend_params=GripParams(...))on real hardware🤖 Generated with Claude Code