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 19f9266..640e266 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 @@ -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()