Skip to content

STARBackend: consolidate iSWAP setup state into iSWAPInformation#1043

Open
BioCam wants to merge 3 commits into
PyLabRobot:mainfrom
BioCam:create-iswap-information
Open

STARBackend: consolidate iSWAP setup state into iSWAPInformation#1043
BioCam wants to merge 3 commits into
PyLabRobot:mainfrom
BioCam:create-iswap-information

Conversation

@BioCam
Copy link
Copy Markdown
Collaborator

@BioCam BioCam commented May 15, 2026

Bundles the 7 scattered _iswap_* setup attributes into one iSWAPInformation dataclass, mirroring the existing Head96Information / MachineConfiguration pattern. No behavioral change beyond error-message wording.

Why

iSWAP setup state lived in 7 separate private attrs on STARBackend, all populated in set_up_iswap() from EEPROM, all immutable post-setup. There was no iSWAPInformation equivalent to the 96-head / machine-config records PLR already has. Costs:

  • Simulation friction: chatterbox would need to set 7 attrs by hand to make iswap_request_pose work.
  • Inconsistent guards: each call site had its own "is iSWAP set up?" check with a different message.
  • v1b1 drift: v1b1's KX2 uses a single KX2Config record; iSWAP had no equivalent.

Changes

STAR_backend.py

  • New @dataclass iSWAPInformation: fw_version, rotation_drive_x_offset, rotation_drive_y_max, link_1_length, link_2_length, rotation_drive_predefined_increments, wrist_drive_predefined_increments.
  • __init__: 7 attrs → one self._iswap_information: Optional[iSWAPInformation].
  • New guarded iswap_information property (raises if setup hasn't run).
  • set_up_iswap(): 6 separate assignments → one iSWAPInformation(...) construction; fw_version now loaded eagerly (was lazy).
  • 9 call sites migrated to self.iswap_information.*; dead lazy-fetch fallbacks removed.

STAR_chatterbox.py

  • _DEFAULT_ISWAP_INFORMATION constant (Hamilton factory defaults).
  • iswap_information constructor override param.
  • One-line assignment in setup() when iSWAP installed.

STAR_tests.py

  • TestiSWAPRequestPose._make_backend simplified (13 lines → 1).
  • +5 tests: property guard (×2), chatterbox default/override/skip (×3).

@BioCam BioCam requested a review from rickwierenga May 15, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant