Skip to content

v1: PreciseFlex: split the package into per-concern modules#1100

Merged
BioCam merged 4 commits into
PyLabRobot:v1b1from
BioCam:precise-flex-split
Jun 22, 2026
Merged

v1: PreciseFlex: split the package into per-concern modules#1100
BioCam merged 4 commits into
PyLabRobot:v1b1from
BioCam:precise-flex-split

Conversation

@BioCam

@BioCam BioCam commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Splits the single 2400-line precise_flex.py into per-concern modules, matching the layout already used by larger backends in the tree (the Hamilton STAR backend, and the KX2 arm backend in #880): a thin device front-end over a driver / capability-backend / kinematics / config split, with tests as a package.

Important for review: the large diff in the first commit is a move, not a rewrite. precise_flex.py is split across new files; no logic changed and the public API is identical (everything still imports from pylabrobot.brooks.precise_flex). git renders it as a big delete plus adds because a one-to-four file split cannot be shown as renames. The clearest way to review it is to confirm the public surface is unchanged and that the tests pass.

Module map:

  • config.py - the Axis enum and the resolved PreciseFlexConfiguration record
  • driver.py - pure transport: the socket I/O connection and device lifecycle
  • kinematics.py - FK/IK and the value types it produces and consumes (PreciseFlexCartesianPose, WorkEnvelope, orientation/wrist literals)
  • arm_backend.py - the capability backend and its controller-reply parsers
  • precise_flex.py - the thin per-model device front-ends
  • errors.py - the controller reply-code table and PreciseFlexError
  • tests/ - a package, split per module (kinematics_tests.py, arm_backend_tests.py)

The dependency graph is acyclic: kinematics is the leaf, config depends only on it, driver depends on nothing PreciseFlex-specific, and arm_backend and the front-ends sit on top.

The second commit is the one behavioural change: setup() now emits a single structured summary line (name, connection, firmware, configuration, capabilities) instead of two separate INFO lines, and adds the module docstring errors.py was missing.

No public API change. Existing tests pass; the package is lint, format, and isort clean and adds no new type errors.

🤖 Generated with Claude Code

BioCam and others added 4 commits June 22, 2026 14:07
…s / arm_backend modules

Restructure only, no behaviour change. The single 2400-line `precise_flex.py` is split into the
per-concern module layout already used by the KX2 backend (`pylabrobot/paa/kx2`):

- `config.py` - the `Axis` enum and the resolved `PreciseFlexConfiguration` record
- `driver.py` - pure transport: the socket I/O connection and device lifecycle
- `kinematics.py` - FK/IK plus the value types it produces/consumes (`PreciseFlexCartesianPose`,
  `WorkingVolume`, the orientation/wrist literals)
- `arm_backend.py` - the capability backend and its controller-reply parsers
- `precise_flex.py` - the thin per-model device front-ends

`tests/` becomes a package, split per module (`kinematics_tests.py`, `arm_backend_tests.py`).

`driver` depends on nothing PreciseFlex-specific; `config` depends only on `kinematics`; there are no
import cycles. Public imports via the package `__init__` are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… errors module

`setup()` now logs a single structured summary of the discovered device instead of two separate
lines. `_log_configuration_summary` reports five fields - name, connection (`host:port`), firmware
(GPL/TCS), this unit's configuration (model, robot type, axes, rail, gripper variant), and the
resulting capabilities (reach class, link lengths, modules) - and the driver's separate
`connected: port=` line is demoted to DEBUG so exactly one INFO summary fires at setup.

Also adds the module docstring `errors.py` was missing, so every module in the package is documented.

No public API change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Marks off the three concerns in `kinematics.py` with the package's boxed comment dividers:
value types, kinematic parameters, and forward / inverse kinematics. Comments only, no code change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Renames the class, the `work_envelope` property, and the re-export to the standard
robotics term for an arm's reachable region.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@BioCam BioCam merged commit 9f06718 into PyLabRobot:v1b1 Jun 22, 2026
1 of 19 checks passed
@BioCam BioCam deleted the precise-flex-split branch June 22, 2026 14:22
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