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

Add aperture position readbacks #385 #395

Merged
merged 6 commits into from
Mar 20, 2024
Merged

Conversation

katesmith280
Copy link
Collaborator

Fixes #385

Instructions to reviewer on how to test:

  1. Run tests

Checks for reviewer

  • Would the PR title make sense to a scientist on a set of release notes
  • If a new device has been added does it follow the standards

@DominicOram DominicOram requested a review from d-perl March 20, 2024 10:11
@DominicOram
Copy link
Contributor

Adding @dperl-dls as a reviewer too as I don't have lots of time at the moment. We'll see who gets to it first though

Copy link
Contributor

@d-perl d-perl left a comment

Choose a reason for hiding this comment

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

Looks great, just one minor comment

elif int(self.aperture.small.get()) == 1:
return self.aperture_positions.SMALL
elif current_ap_y <= self.ROBOT_LOAD_Y:
return self.aperture_positions.ROBOT_LOAD
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: I feel that the robot load position should still have some tolerance on it - probably the same MRES * some n steps as before - otherwise we'll still end up with similar issues where the state is unrecognised when the current_ap_y is just a hair short of the canonical ROBOT_LOAD position. Since this position is well out of the way of collisions we can probably increase the default number of steps to 5 or something.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I suggested this logic to @katesmith280. I'm happy with a tolerance or without given that it's just a less than at the moment (so has some tolerance built in). If you think tolerance improves it then that's fine by me

Copy link
Collaborator Author

@katesmith280 katesmith280 Mar 20, 2024

Choose a reason for hiding this comment

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

I pushed a new change that decoupled the the robot load position (31.4mm) and the permitted tolerance (5 mm). So the aperture position value ROBOT_LOAD now has a bit more meaning, i.e. position plus tolerance.

I may not have done this in the most elegant way so any improvemens are greatly appreciated

Copy link
Contributor

@d-perl d-perl Mar 20, 2024

Choose a reason for hiding this comment

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

@DominicOram Oh, sorry. Yeah it's not critical, we could always address it later if it causes problems - I did see the <= but was just worried that that tolerance was only one-sided and won't work if the move to robot load stopped slightly before the position, so I do think it's more robust with that in.

@katesmith280 great, I'll have a look now

assert ap_sg._get_current_aperture_position() == aperture_positions.ROBOT_LOAD


def test_aperture_positions_robot_load_unsafe(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: a test similar to these two for the above tolerance would be good

Copy link

codecov bot commented Mar 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.46%. Comparing base (30815f1) to head (67b7152).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #395   +/-   ##
=======================================
  Coverage   93.45%   93.46%           
=======================================
  Files          90       90           
  Lines        3377     3380    +3     
=======================================
+ Hits         3156     3159    +3     
  Misses        221      221           

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

Copy link
Contributor

@d-perl d-perl left a comment

Choose a reason for hiding this comment

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

Sorry I missed this detail in my last review, that part is quite important - Hopefully the new comment is clearer but feel free to ask me if you have any questions about it

@@ -89,11 +88,13 @@ class ApertureScatterguard(InfoLoggingDevice):
scatterguard = Cpt(Scatterguard, "-MO-SCAT-01:")
aperture_positions: Optional[AperturePositions] = None
TOLERANCE_STEPS = 3 # Number of MRES steps
ROBOT_LOAD_TOLERANCE = 5 # Number of mm from ROBOT_LOAD_Y
Copy link
Contributor

@d-perl d-perl Mar 20, 2024

Choose a reason for hiding this comment

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

Oh, sorry, I didn't notice this before - we can't use a hardcoded position here because they need to be able to be adjusted in a configuration file (used by both GDA and Hyperion), so we load the positions in to self.aperture_positions on creating this device. 5 mm is also too big of a tolerance, I was suggesting 5 times the spatial resolution of the motor.

So then in _get_current_aperture_position you can compare current_ap_y to that dynamically loaded position value with the calculated tolerance loaded from the motor, something like:

def _get_current_aperture_position(self) -> SingleAperturePosition:
    ...
    robot_load_ap_y = self.aperture_positions.ROBOT_LOAD.location.aperture_y
    tolerance = self.TOLERANCE_STEPS * self.aperture.y.motor_resolution.get()
    ...
    elif current_ap_y <=  + robot_load_ap_y + tolerance:
    ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @dperl-dls - I've added in these abstractions now and just updated the tests to also call them (instead of the hard coded within ant outside tolerance values)

Copy link
Contributor

@d-perl d-perl left a comment

Choose a reason for hiding this comment

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

Great, thanks! I added a suggestion to fix a typo, otherwise looks good to me, you can merge this whenever you like now

@katesmith280 katesmith280 merged commit 60363f9 into main Mar 20, 2024
5 of 6 checks passed
@katesmith280 katesmith280 deleted the 385_aperture_readback_PVs branch March 20, 2024 14:13
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.

Use existing PVs for Aperture Scatterguard location
3 participants