Skip to content

Avoid resetting Alpao DM on script exit by default - #60

Open
mbonaglia wants to merge 2 commits into
mainfrom
fix/alpao-hold-shape-on-exit
Open

Avoid resetting Alpao DM on script exit by default#60
mbonaglia wants to merge 2 commits into
mainfrom
fix/alpao-hold-shape-on-exit

Conversation

@mbonaglia

@mbonaglia mbonaglia commented Aug 25, 2026

Copy link
Copy Markdown

Summary

  • Add reset_on_connect and reset_on_close flags to AlpaoDm / BaseAlpaoMirror (both default True, preserving previous behaviour).
  • Wire Alpao SDK ResetOnClose from reset_on_close so teardown (including Ctrl-C) respects the flag even when deinitialize() is skipped.
  • Add deinitialize(reset=...) for explicit teardown control.

To hold the last commanded shape across script exit or reconnect:

dm = AlpaoDm(820, reset_on_connect=False, reset_on_close=False)

Test plan

  • Default AlpaoDm(nacts=...) still zeros on connect and on normal exit / deinitialize().
  • AlpaoDm(..., reset_on_close=False): command a non-flat shape, exit with Ctrl-C — mirror retains shape.
  • AlpaoDm(..., reset_on_connect=False, reset_on_close=False): reconnect without clearing held shape.

alfiopuglisi and others added 2 commits August 25, 2026 12:03
The Alpao SDK resets actuators when the DM handle is destroyed unless
ResetOnClose is disabled. Add reset_on_connect and reset_on_close flags
so scripts can hold the last commanded shape across exit and Ctrl-C.

Co-authored-by: Cursor <cursoragent@cursor.com>
Preserve existing opticalib behaviour (zero on connect and teardown)
while still allowing callers to opt out and hold the last shape.

Co-authored-by: Cursor <cursoragent@cursor.com>
self,
serial_number: str | None,
n_acts: int | str | None,
use_plico: bool = False,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the use_plico variable? Please, remove it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This de-initialization option (keep or don't keep last command) can be more easily handled with the __close__ dunder and a setting in the device's configuration.
This also handles the case of CTRL+D or CTRL+C in runtime, and if for some reason a public method is needed, just call de __close__ on deinitialize (though it would not make sense)

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.

3 participants