This commit is contained in:
2023-06-20 16:10:03 +02:00
parent 7659226aa2
commit 574605f583
2 changed files with 83 additions and 65 deletions

View File

@@ -1421,8 +1421,9 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
for go in cldLst:
if type(go)==UsrGO.Fiducial:
continue
if type(go)!=UsrGO.FixTargetFrame:
_log.warning(f'for now: ONLY FixTargetFrame are supported ->skipped:{go}')
t=type(go)
if t not in(UsrGO.FixTargetFrame,UsrGO.Path):
_log.warning(f'{t} not supported for FixTargetFrame ->skipped:{go}')
continue
try:
param=go.get_scan_param() #points in coordinate system of ROI
@@ -1431,23 +1432,19 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
continue
p=param['points']
trf=np.asmatrix(param['trf']*1000) #fix shear/rotation mm->um
pos=np.array(param['grid']['pos']) #in um
pitch=np.array(param['grid']['pitch']) #in um
trf[:,0]*=-1 #X axis has inverted sign !
if t==UsrGO.FixTargetFrame:
pos=np.array(param['grid']['pos']) #in um
pitch=np.array(param['grid']['pitch']) #in um
m=np.hstack((p*pitch+pos,np.ones((p.shape[0],1))))
p=(np.asmatrix(m)*trf).A
param['pts_trf']=p # transformed points
else:
m=np.hstack((p,np.ones((p.shape[0],1))))
p=(np.asmatrix(m)*trf).A
param['pts_trf']=p # transformed points
#t=np.matrix((0,0,1)).T
#for i in range(p.shape[0]):
# t.A[:2,0]=pos+p[i,:]*pitch
# p[i,:]=(trf*t).A.ravel()
# Same but much faster !
m=np.hstack((p*pitch+pos,np.ones((p.shape[0],1))))
p=(np.asmatrix(m)*trf).A
p[:,0]*=-1 #X axis has inverted sign !
param['ptsTrf']=p # transformed points
param['numPts']=p.shape[0]
#param['points']=p
# add up to 100 test fiducial
param['num_pts']=p.shape[0]
vb=self.vb
grp=self._goTracked
mft=self._moduleFixTarget
@@ -1475,9 +1472,6 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
#_log.debug(f'step to 2nd point:{p[1,:]-p[0,:]}')
#print('DEBUG: difference from point to point:')
#print(np.diff(p, axis=0))
#param['codeGen']=0
param['codeGen']=1
param['codeGen']=2
self.daq_collect(**param)
elif task == TASK_GRID:
@@ -2037,26 +2031,25 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch)
w,h=(30, 22)
go=UsrGO.Grid((fx-w/2,fy-h/2), (w, h), (30, 22), .1)
elif idx==5:
ofs=(0, 0);
width=10;
fidScl=.02
fiducial=((-.2, -.2), (-.2, 2.4), (10.2, -.2), (10.2, 2.4))
ofs=(.2, .2); width=10; fidScl=.02
fiducial=((.1, .1), (.1, 2.7), (10.3, .1), (10.3, 2.7))
if param:
p=json.loads('{'+param+'}') # "ofs":[10, 5],"width":200,"fidScl":0.5,"fiducial":[[18,7],[25,16],[70, 20]]
locals().update(p)
fiducial=np.array(fiducial)
gp=psi_device.shapepath.GenPath();
gp.swissmx_points(ofs=ofs, width=width, flipy=True)
go=UsrGO.Path((fx-width/2, fy-1.2), gp.points, fiducial, fidScl)
gp=psi_device.shapepath.GenPath(); gp.swissmx_points(ofs=ofs, width=width, flipy=True)
sz=gp.points.max(0)+np.array(ofs)*2
go=UsrGO.Path((fx-sz[0]/2, fy-sz[1]/2), sz, gp.points, fiducial, fidScl)
elif idx==6:
ofs=(0, 0); width=10; fidScl=.02
fiducial=((-.2, -.2), (-.2, 2.0), (10.2, -.2), (10.2, 2.0))
ofs=(.2, .2); width=10; fidScl=.02
fiducial=((.1, .1), (.1, 2.2), (10.3, .1), (10.3, 2.2))
if param:
p=json.loads('{'+param+'}') # "ofs":[10, 5],"width":200,"fidScl":0.5,"fiducial":[[18,7],[25,16],[70, 20]]
locals().update(p)
fiducial=np.array(fiducial)
gp=psi_device.shapepath.GenPath();gp.swissfel_points(ofs=ofs, width=width,flipy=True)
go=UsrGO.Path((fx-width/2,fy-1.2), gp.points, fiducial, fidScl)
gp=psi_device.shapepath.GenPath(); gp.swissfel_points(ofs=ofs, width=width,flipy=True)
sz=gp.points.max(0)+np.array(ofs)*2
go=UsrGO.Path((fx-sz[0]/2, fy-sz[1]/2), sz, gp.points, fiducial, fidScl)
else:
_log.error('index not handeled')
@@ -2146,13 +2139,13 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch)
def daq_collect(self, **kwargs):# points, visualizer_method, visualizer_params):
'''
kwargs:
codeGen: 0 pvt motion using ptsTrf
1 pvt motion using trf and points
2 pvt motion, compact grid code
grid: grid dictionary with orig, pitch, count
trf: transformation matrix
points: list of points without transformation
ptsTrf: list of points with transformation
code_gen: 0 pvt motion using ptsTrf
1 pvt motion using trf and points
2 pvt motion, compact grid code
grid: grid dictionary with orig, pitch, count
trf: transformation matrix
points: list of points without transformation
pts_trf: list of points with transformation
'''
app = QApplication.instance()
cfg = app._cfg
@@ -2184,12 +2177,12 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch)
#dlg.setAutoClose(True)
#dlg.show()
dlg.setLabelText("Setup Gather/Sync");dlg+=5
sp.setup_gather(kwargs['numPts'])
sp.setup_gather(kwargs['num_pts'])
sp.setup_sync(verbose=sp.verbose&0x40, timeOfs=dt_misc['time_ofs'], timeCor=dt_misc['time_cor'])
dlg.setLabelText("Download motion program");dlg+=5
codeGen=kwargs['codeGen']
codeGen=kwargs['code_gen']
if codeGen==0:
sp.setup_motion(fnPrg=fn+'.prg', mode=3, scale=1., dwell=10, points=kwargs['ptsTrf'])
sp.setup_motion(fnPrg=fn+'.prg', mode=3, scale=1., dwell=10, points=kwargs['pts_trf'])
elif codeGen==1:
sp.setup_motion(fnPrg=fn+'.prg', mode=3, scale=1., dwell=10, points=kwargs['points'])
elif codeGen==2:
@@ -2201,17 +2194,23 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch)
# Z is in um -> therefore the offset must be multiplied with 1000 ! Z motor has opposite sign !
cz=f'{+p[0]:+.18g}X{-p[1]:+.18g}Y{-p[2]*1000:+.18g}'
else:
trf=kwargs['trf']
cz=f'{+p[0]:+.18g}X{-p[1]:+.18g}Y{-p[2]*1000:+.18g}'
except AttributeError:
cz='0'
if codeGen==0:
fx='X';fy='Y'
else:
trf=kwargs['trf']*1000#fix shear/rotation mm->um
fx=f'{trf[0,0]:+.18g}X{trf[1,0]:+.18g}Y{trf[2,0]:+.18g}'
fy=f'{trf[0,1]:+.18g}X{trf[1,1]:+.18g}Y{trf[2,1]:+.18g}'
_log.warning('no plane fitting done. z does not move')
trf=kwargs['trf']*1000 # fix shear/rotation mm->um
trf[:, 0]*=-1 # X axis has inverted sign !
if codeGen==0:
fx='X';fy='Y'
else:
fx=f'{trf[0,0]:+.18g}X{trf[1,0]:+.18g}Y{trf[2,0]:+.18g}'
fy=f'{trf[0,1]:+.18g}X{trf[1,1]:+.18g}Y{trf[2,1]:+.18g}'
print(f'pts_trf[0,:]={kwargs["pts_trf"][0, :]}')
print(f'points[0,:]={kwargs["points"][0, :]}')
print(f'trf=\n{trf}')
sp.setup_coord_trf(fx, fy, cz) # reset to shape path system
try: