Avoid resetting Alpao DM on script exit by default - #60
Open
mbonaglia wants to merge 2 commits into
Open
Conversation
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, |
Collaborator
There was a problem hiding this comment.
Why the use_plico variable? Please, remove it.
pietroferraiuolo
requested changes
Aug 25, 2026
Collaborator
There was a problem hiding this comment.
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
reset_on_connectandreset_on_closeflags toAlpaoDm/BaseAlpaoMirror(both defaultTrue, preserving previous behaviour).ResetOnClosefromreset_on_closeso teardown (including Ctrl-C) respects the flag even whendeinitialize()is skipped.deinitialize(reset=...)for explicit teardown control.To hold the last commanded shape across script exit or reconnect:
Test plan
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.