perf(LamNI): skip redundant lsamrot rotate-to-0 right after loptics_out()
loptics_out() already drives lsamrot to 0 via RtLamniController.feedback_enable_with_reset() when rtx is enabled, so the explicit tomo_rotate(0) that followed in find_rotation_center() and find_rotation_center_smear_experimental() was reissuing a move that had mostly already happened -- align() already skips this same step (see its commented-out disable/rotate/re-enable at the equivalent spot). _tomo_rotate_if_needed() keeps the still-needed pieces: it still corrects small residual drift from feedback briefly running before _disable_rt_feedback(), and still performs the move when rtx is disabled (loptics_out() then never touches lsamrot at all). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit was merged in pull request #275.
This commit is contained in:
@@ -132,6 +132,21 @@ class XrayEyeAlign:
|
||||
def get_tomo_angle(self) -> float:
|
||||
return self.device_manager.devices.lsamrot.readback.read()["lsamrot"]["value"]
|
||||
|
||||
def _tomo_rotate_if_needed(self, val: float, tol: float = 0.05):
|
||||
"""Rotate lsamrot to `val` unless it's already there.
|
||||
|
||||
Used right after loptics_out(), which -- when rtx is enabled -- already
|
||||
drives lsamrot to 0 via feedback_enable_with_reset()
|
||||
(RtLamniController.feedback_enable_with_reset() in rt_lamni_ophyd.py).
|
||||
Re-issuing the same move there would be a redundant round trip; this
|
||||
still corrects the small residual drift that can creep in while
|
||||
feedback briefly runs between that internal move and the explicit
|
||||
_disable_rt_feedback() call, and still moves lsamrot when rtx is
|
||||
disabled (loptics_out() then never touches it at all).
|
||||
"""
|
||||
if not np.isclose(self.get_tomo_angle(), val, atol=tol):
|
||||
self.tomo_rotate(val)
|
||||
|
||||
def _disable_rt_feedback(self):
|
||||
self.device_manager.devices.rtx.controller.feedback_disable()
|
||||
|
||||
@@ -860,7 +875,7 @@ class XrayEyeAlign:
|
||||
self.send_message("Please wait - moving sample in...")
|
||||
self.lamni.loptics_out()
|
||||
self._disable_rt_feedback()
|
||||
self.tomo_rotate(0)
|
||||
self._tomo_rotate_if_needed(0)
|
||||
self.update_frame(keep_shutter_open)
|
||||
self.gui.set_crosshair_position(fzp_x / self.pixel_calibration, fzp_y / self.pixel_calibration)
|
||||
self.gui.show_crosshair()
|
||||
@@ -1150,7 +1165,7 @@ class XrayEyeAlign:
|
||||
self.send_message("Please wait - moving sample in...")
|
||||
self.lamni.loptics_out()
|
||||
self._disable_rt_feedback()
|
||||
self.tomo_rotate(0)
|
||||
self._tomo_rotate_if_needed(0)
|
||||
self.update_frame(keep_shutter_open)
|
||||
self.gui.set_crosshair_position(fzp_x / self.pixel_calibration, fzp_y / self.pixel_calibration)
|
||||
self.gui.show_crosshair()
|
||||
|
||||
Reference in New Issue
Block a user