Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get mirror immediate position #743

Merged
merged 8 commits into from
Dec 13, 2024
Merged

Get mirror immediate position #743

merged 8 commits into from
Dec 13, 2024

Conversation

dc2917
Copy link
Contributor

@dc2917 dc2917 commented Dec 11, 2024

Description

This PR enables getting the immediate position of stepper motors while they are moving.
Previously, querying the position during motion would return None. Now, for the ST10, an estimated position is returned.

I've had a go at making the dummy stepper motor return a position based on its QTimer interval and remaining time, but it's not fully complete, so we can either address that separately or I can finish it up here.

Fixes #691

Type of change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation (non-breaking change that adds or improves the documentation)
  • Optimisation (non-breaking, back-end change that speeds up the code)

Key checklist

  • Pre-commit hooks run successfully (pre-commit run -a)
  • All tests pass (pytest)
  • The documentation builds without warnings (mkdocs build -s)
  • Check the GUI still works (if relevant)
  • Check the code works with actual hardware (if relevant)
  • Check the pyinstaller-built executable works (if relevant)

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests have been added or an issue has been opened to tackle that in the future. (Indicate issue here: # (issue))

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.90%. Comparing base (bd2ba61) to head (9ec257a).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #743      +/-   ##
==========================================
+ Coverage   86.87%   86.90%   +0.03%     
==========================================
  Files          69       69              
  Lines        3557     3551       -6     
==========================================
- Hits         3090     3086       -4     
+ Misses        467      465       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dc2917 dc2917 requested a review from alexdewar December 12, 2024 08:32
@dc2917 dc2917 marked this pull request as ready for review December 12, 2024 08:33
Copy link
Collaborator

@alexdewar alexdewar left a comment

Choose a reason for hiding this comment

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

I've made one suggestion about the test, but it otherwise looks good. Thanks for doing this!

I think it's fine to leave DummyStepperMotor as it is for now -- let's not make things hard for ourselves.

I've just realised that we also need to update data_file_writer.py, because we record whether or not the motor is moving as a column in the CSV file and it currently does this by checking whether the returned angle is None. Would you mind fixing this up too?

@dc2917
Copy link
Contributor Author

dc2917 commented Dec 13, 2024

I've just realised that we also need to update data_file_writer.py, because we record whether or not the motor is moving as a column in the CSV file and it currently does this by checking whether the returned angle is None. Would you mind fixing this up too?

I've removed that column from the CSV file entirely. I presume that's what we want, since the only way we check for whether the mirror is moving is if it returns None, which will never happen.

@dc2917 dc2917 requested a review from alexdewar December 13, 2024 08:51
Copy link
Collaborator

@alexdewar alexdewar left a comment

Choose a reason for hiding this comment

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

The stepper motor classes do have an is_moving property that you can use instead. Unfortunately we do need this column -- sorry I wasn't clear 😞

@dc2917 dc2917 requested a review from alexdewar December 13, 2024 11:55
Copy link
Collaborator

@alexdewar alexdewar left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for fixing up that extra file 😄

@dc2917 dc2917 merged commit 2348c2e into main Dec 13, 2024
7 checks passed
@dc2917 dc2917 deleted the get_mirror_immediate_position branch December 13, 2024 12:34
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.

Allow for getting current position when stepper motor is moving
2 participants