fix(flomni): stop OSA collision at fosa_in(), correct stale foptz init position
fosa_in() moved fosax/fosay/fosaz straight to their configured "in" positions with no collision check. ffzp_info() already computed OSA-to-pin clearance but never gated the move on it. Add a shared _osa_remaining_space() helper (also used to deduplicate ffzp_info()'s own calculation) and raise FlomniOpticsError in fosa_in() when the computed clearance at the target position is <= 0. Root cause of the specific collision seen: stage init's _align_setup() hardcoded foptz to 23 instead of its calibrated "in" value of 17 (ptycho_flomni.yaml), 6 mm off from what fosaz's own "in" calibration assumes. Hardcode foptz to 17 instead, and lock foptz.limits to +-0.1 mm around it in both set_limits() and _align_setup() so any future move away from 17 requires deliberately widening the limits first. Also corrects the stale "in: 23" in ptycho_flomni.yaml's foptz userParameter to 17. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit was merged in pull request #300.
This commit is contained in:
1 parent
308b4edacd
commit
8936071766
3 files changed
+26
-6
No files matched your search
@@ -305,7 +305,7 @@ class FlomniInitStagesMixin:
|
||||
dev.ftransx.limits = [0, 50]
|
||||
dev.ftray.limits = [-200, 0]
|
||||
dev.fsamy.limits = [2, 3.5]
|
||||
dev.foptz.limits = [22.5, 28]
|
||||
dev.foptz.limits = [17 - 0.1, 17 + 0.1]
|
||||
dev.foptx.limits = [-17, -12]
|
||||
dev.fheater.limits = [-15, 0]
|
||||
dev.feyex.limits = [-18, -1]
|
||||
@@ -333,7 +333,8 @@ class FlomniInitStagesMixin:
|
||||
|
||||
# the fopty 3.87 should put us in place for a lower FZP on the lower FZP chip
|
||||
|
||||
umv(dev.foptz, 23)
|
||||
umv(dev.foptz, 17)
|
||||
dev.foptz.limits = [17 - 0.1, 17 + 0.1]
|
||||
|
||||
flomni_samx_in = dev.fsamx.user_parameter.get("in")
|
||||
if flomni_samx_in is None:
|
||||
|
||||
@@ -5,6 +5,10 @@ from rich.console import Console
|
||||
from rich.table import Table
|
||||
|
||||
|
||||
class FlomniOpticsError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class FlomniOpticsMixin:
|
||||
@staticmethod
|
||||
def _get_user_param_safe(device, var):
|
||||
@@ -13,6 +17,12 @@ class FlomniOpticsMixin:
|
||||
raise ValueError(f"Device {device} has no user parameter definition for {var}.")
|
||||
return param.get(var)
|
||||
|
||||
def _osa_remaining_space(self, fosaz_target: float) -> float:
|
||||
"""Clearance (mm) between the OSA and a normal OMNY pin if fosaz were
|
||||
at `fosaz_target`, at the *current* foptz reading. <=0 means collision."""
|
||||
foptz_val = dev.foptz.readback.get()
|
||||
return -fosaz_target + (33 - foptz_val)
|
||||
|
||||
def feye_out(self):
|
||||
dev.fsh.fshclose()
|
||||
self.foptics_in()
|
||||
@@ -188,6 +198,16 @@ class FlomniOpticsMixin:
|
||||
)
|
||||
|
||||
if need_move_osa:
|
||||
remaining = self._osa_remaining_space(fosaz_in)
|
||||
if remaining <= 0:
|
||||
foptz_val = dev.foptz.readback.get()
|
||||
raise FlomniOpticsError(
|
||||
f"Refusing to move OSA to its IN position: at the current foptz "
|
||||
f"({foptz_val:.2f}), fosaz IN ({fosaz_in:.4f}) would leave "
|
||||
f"{remaining:.2f} mm of clearance to a normal OMNY pin -- a "
|
||||
"collision. Check/recalibrate the fosaz 'in' user parameter for "
|
||||
"the current foptz before proceeding (see ffzp_info())."
|
||||
)
|
||||
umv(dev.fosax, fosax_in, dev.fosay, fosay_in)
|
||||
umv(dev.fosaz, fosaz_in)
|
||||
else:
|
||||
@@ -311,13 +331,12 @@ class FlomniOpticsMixin:
|
||||
console.print(table)
|
||||
|
||||
fosaz_val = dev.fosaz.readback.get()
|
||||
foptz_val = dev.foptz.readback.get()
|
||||
fosaz_in = self._get_user_param_safe("fosaz", "in")
|
||||
|
||||
tol_osa = 0.010 # mm, 10 microns
|
||||
|
||||
remaining_current = -fosaz_val + (33 - foptz_val)
|
||||
remaining_at_in = -fosaz_in + (33 - foptz_val)
|
||||
remaining_current = self._osa_remaining_space(fosaz_val)
|
||||
remaining_at_in = self._osa_remaining_space(fosaz_in)
|
||||
|
||||
print("\nOSA Information:")
|
||||
print(f" Current fosaz {fosaz_val:.1f}")
|
||||
|
||||
@@ -144,7 +144,7 @@ foptz:
|
||||
readoutPriority: baseline
|
||||
connectionTimeout: 20
|
||||
userParameter:
|
||||
in: 23
|
||||
in: 17
|
||||
deviceTags:
|
||||
- ptycho_flomni
|
||||
|
||||
|
||||
Reference in new issue
Block a user