Skip to content

PreciseFlex: split setup() into connect(), initialize() and disconnect() - #1237

Closed
miikee wants to merge 1 commit into
PyLabRobot:mainfrom
Cheshire-Labs:u1-lifecycle
Closed

PreciseFlex: split setup() into connect(), initialize() and disconnect()#1237
miikee wants to merge 1 commit into
PyLabRobot:mainfrom
Cheshire-Labs:u1-lifecycle

Conversation

@miikee

@miikee miikee commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

setup() did four things behind one name: open the socket, agree the response
mode, raise high power and attach, then home. A caller that wants to read a
position, or to reconnect after a controller restart, had no way to ask for
part of that.

  • connect() opens the link and sets the response mode.
  • initialize() raises power, attaches, leaves freedrive, and reads the
    controller's configuration.
  • disconnect() detaches, drops power and closes the link.

Neither connect nor initialize moves the arm; home() is still the only
verb that sweeps it. setup() calls all of them in order, so existing callers
are unaffected.

Configuration discovery moves into _discover_configuration() and stays
best-effort. Because it can fail, has_configuration says whether the arm
actually read its own limits, which a caller that would rather adapt than be
raised at can now check.

One ordering change worth flagging: stop_freedrive_mode and configuration
discovery now run before home() rather than after. Freedrive off before homing
is the safer order, but it is a behaviour change, not a pure refactor.
_handle_out_of_range_axes still runs after home(), as before.

11 new tests cover the split, including that bring-up sends no motion command.

Draft: first of five on this file. The rest are ready and will follow as this
lands, since a PR base has to be a branch in this repo.

setup() did four things behind one name: open the socket, agree the response
mode, raise high power and attach, then home. A caller that wants to read a
position, or to reconnect after a controller restart, had no way to ask for
part of that.

connect() opens the link and sets the response mode. initialize() raises
power, attaches, leaves freedrive and reads the controller's configuration.
disconnect() detaches, drops power and closes the link. Neither connect nor
initialize moves the arm; home() is still the only verb that sweeps it, and
setup() still calls all of them in order, so existing callers are unaffected.

Configuration discovery moves into _discover_configuration() and stays
best-effort. Because it can fail, has_configuration says whether the arm
actually read its own limits, which a caller that would rather adapt than be
raised at can now check.
@miikee

miikee commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1239, which carries this commit plus the other four PreciseFlex changes as one PR. Verified: this branch's tip is an ancestor of #1239's head, so nothing is dropped. Closing to keep one PR per subsystem rather than a chain.

@miikee miikee closed this Sep 3, 2026
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