Skip to content

STARBackend: consolidate iSWAP setup state into iSWAPInformation#1043

Merged
BioCam merged 2 commits into
PyLabRobot:mainfrom
BioCam:create-iswap-information
May 19, 2026
Merged

STARBackend: consolidate iSWAP setup state into iSWAPInformation#1043
BioCam merged 2 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
@rickwierenga
Copy link
Copy Markdown
Member

Tested on real hardware — backend.iswap_information returns cleanly after lh.setup(). Output from my STAR:

fw_version:                4.1S 2011-12-19
rotation_drive_x_offset:   32.6 mm
rotation_drive_y_max:      628.41 mm
link_1_length:             138.0 mm
link_2_length:             137.7 mm
rotation_drive_predefined_increments:
  LEFT          -29114
  FRONT             88
  RIGHT          29068
  PARKED_RIGHT   29500
wrist_drive_predefined_increments:
  RIGHT         -26577
  STRAIGHT       -8912
  LEFT            8878
  REVERSE        26776

Single attribute access, no scattered EEPROM queries — works as advertised.

@BioCam
Copy link
Copy Markdown
Collaborator Author

BioCam commented May 18, 2026

works as advertised

The praise I always wanted 😂

@BioCam BioCam force-pushed the create-iswap-information branch from c0ebab4 to 520eac9 Compare May 18, 2026 23:41
@BioCam BioCam merged commit 8b0ccb8 into PyLabRobot:main May 19, 2026
21 checks passed
@BioCam BioCam deleted the create-iswap-information branch May 19, 2026 00:03
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.

2 participants