From 527fcec7f5ea096ded189788287bad3adca9ab1d Mon Sep 17 00:00:00 2001 From: Thierry Zamofing Date: Mon, 25 Nov 2024 09:58:55 +0100 Subject: [PATCH] wip(0) --- hit_return.svg | 430 +++++++++++++++++--------------- python/hit_return_evaluation.py | 100 +++++--- python/shapepath.py | 18 +- 3 files changed, 307 insertions(+), 241 deletions(-) diff --git a/hit_return.svg b/hit_return.svg index 38c0131..f46e3df 100644 --- a/hit_return.svg +++ b/hit_return.svg @@ -19,6 +19,51 @@ sodipodi:docname="hit_return.svg"> + + + + + + + + + - - - - - - - - - - 8 - - - - 8 - - - - - + + + + + + + - - - - - + + + + + + + + + + + + + + + diff --git a/python/hit_return_evaluation.py b/python/hit_return_evaluation.py index 22d32db..36f4457 100755 --- a/python/hit_return_evaluation.py +++ b/python/hit_return_evaluation.py @@ -30,16 +30,23 @@ class HitReturnEval: h3=ax.plot(pts[:,0],pts[:,1],'g-') h2=ax.plot(pts[:,0],pts[:,1],'y-') h1=ax.plot(pts[:,0],pts[:,1],'r.') + ha=ax.arrow(4, 2, 0.5, 0.5, head_width=0.05, head_length=0.1, fc='k', ec='k') + #cid = fig.canvas.mpl_connect('button_press_event', self.onclick) #fig.obj=self plt.axis('equal') plt.ion() fig.show() - self._plt=(fig,ax,h1[0],h2[0]) + self._plt=[fig,ax,h1[0],h2[0],ha] - def updatePlt(self,pts): - fig, ax, h1, h2=self._plt + def updatePlt(self,pts,vx,vy): + fig,ax,h1,h2,ha=self._plt + x,y=pts[-1][:2] pts=np.array(pts) + ha.remove() + l=(vx**2+vy**2)**.5 + ha=ax.arrow(x,y,.7*vx,.7*vy, head_width=.2, head_length=0.3*l, fc='k', ec='k',zorder=5) + self._plt[-1]=ha h1.set_xdata((pts[:,0])) h1.set_ydata((pts[:,1])) h2.set_xdata((pts[:,0])) @@ -56,8 +63,10 @@ class HitReturnEval: g=kwargs['grid'] ox,oy=g['pos'] #origin position in um (or counts if scaled) px,py=g['pitch'] #pitch to next position in um (or 1 if scaled) - nx,ny=g['count'] #total count of wells - sx,sy=kwargs['ssz'] #section size (in wells) + nx,ny=g['count'] #total count of wells + sx,sy=kwargs['ssz'] #section size (in wells) + tx,ty=nx//sx,ny//sy #total sections + #smv=kwargs['smv'] #time(in num of shots) to move to next section (horiz/vert) #swait=kwargs['smv'] #wait after section for motion trigger. swait=0:never wait @@ -72,45 +81,78 @@ class HitReturnEval: # | | | | | | | | | | | | # 1-2 1-2 1-2 1-2 1-2 1-2 - r=0 #row - x0,y0,n=0,-1,0 # counter well in region + k=-1 # key position + cx,cy=0,0 # section counter + x0,y0,n=0,0,0 # counter well in region dx,dy=0,1 # motion pitch - x1,y1=0,0 #counter region start + vsx=vsy=1 # scaled velocity + vx,vy=0,vsy # scaled velocity mv=list() while(True): + if cy%2==0: # even rows + x=sx*cx+x0;y=sy*cy+y0 + else: # odd rows + x=(tx-cx)*sx-x0-1;y=sy*cy+y0 + vx=-vx x0+=dx;y0+=dy - print(f'{x0+x1} {y0+y1} ({dx}|{dy}|{n})') - mv.append((x0+x1+.1*n,y0+y1+.1*n,n)) - self.updatePlt(mv) + print(f'X{x}:{vx} Y{y}:{vy} ({k}|{dx}|{dy}|{n})') + mv.append((x+.1*n,y+.1*n,n)) + self.updatePlt(mv,vx,vy) + if k>=0: #if keypoint not directly followed by an other keypoint, define future velocity + if k in (0,4): + vx,vy=0,vsy + elif k==2: + vx,vy=0,-vsy + elif k==5: + vx,vy=-vsx,0 + elif k==6: + n+=1 + elif k==7: + print('next h section') + cx+=1 + x0,y0,n,dx,dy=0,0,0,0,0 + elif k==8: + print('next v section') + cx=0;cy+=1 + x0,y0,n,dx,dy=0,0,0,0,0 + if cy>=ty: + print('finished whole grid') + break # + else: + raise ValueError('should never happened') + print(f'vx|vy after keypoint {k}: ({vx}|{vy})') + k=-1 if y0==sy-1: if dy==1: #(1) dx,dy=1,0 + vx,vy=vsx/2,vsy/2 else: - dx,dy=0,-1#(2) - elif y0==1 and x00 and x00:#(7 odd) - x1-=sx - elif y1+2*sy<=ny:#(8) - y1+=sy;r+=1 - else: - break #finished whole grid - print('next regionA') - x0,y0,n=0,0,0 - dx,dy=0,0 + if cx0){{ //(7 odd) {x1}-={sx} - {vx}=-{vsx};{vy}=0 + {vx}=0;{vy}=0 pvt{pt2pt_time*tmx} abs;{t}={tmx} }} else if ({y1}+2*{sy}<={ny}){{ //(8) @@ -1093,7 +1093,7 @@ enable plc 2 {vx}=0;{vy}={vsy} }}else{{ // (5) {dx}=-1;{dy}=0 - {vx}=-{vsx};{vy}=0 + {vx}=-{vsx}/2;{vy}=-{vsy}/2 }} }} }} @@ -1299,8 +1299,8 @@ if __name__=='__main__': elif mode==6: grid={'pos':(-1000, -1200), 'pitch':(120, 120), 'count':(16, 20)} # section size (in wells) - ssz=(4, 5) - #ssz=(6, 10) + #ssz=(4, 5) + ssz=(6, 10) #ssz=(2, 5) #sdelay=ssz[0]*ssz[1] # wait after section for motion trigger. swait=0:never wait sp.setup_motion(fnPrg=fn+'.prg',scale=1.,cnt=1,dwell=100,mode=6,grid=grid,ssz=ssz)