From 1af89d1dd4c06bfacc38f857d797ca36a9d01bd0 Mon Sep 17 00:00:00 2001 From: x01dc Date: Mon, 27 Jul 2026 10:19:21 +0200 Subject: [PATCH] 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 --- .../plugins/LamNI/x_ray_eye_align.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/plugins/LamNI/x_ray_eye_align.py b/csaxs_bec/bec_ipython_client/plugins/LamNI/x_ray_eye_align.py index 9abe225..f04d42c 100644 --- a/csaxs_bec/bec_ipython_client/plugins/LamNI/x_ray_eye_align.py +++ b/csaxs_bec/bec_ipython_client/plugins/LamNI/x_ray_eye_align.py @@ -129,6 +129,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() @@ -836,7 +851,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() @@ -1126,7 +1141,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()