cleanup helicalscan
This commit is contained in:
@@ -661,7 +661,7 @@ class HelicalScan:
|
||||
ax.set_zlim(v[1]-l2, v[1]+l2)
|
||||
|
||||
|
||||
def gen_coord_trf_code(self,file=None,host=None):
|
||||
def gen_coord_trf_code(self):
|
||||
param=self.param
|
||||
prg = []
|
||||
prg.append('''
|
||||
@@ -771,122 +771,10 @@ open inverse
|
||||
close
|
||||
''')
|
||||
|
||||
# ****** TESTING CODE ******
|
||||
#this is testcode to check linear coordinate transformation and
|
||||
#simple (same as before) fwd and inv-kinematics
|
||||
#When using pvt mode they do not behave the same:
|
||||
#(Power PMAC Users Manual P648)
|
||||
#Enabling Move Segmentation:
|
||||
#If segmentation mode is disabled, a circle-mode move will execute as a linear-mode move
|
||||
#directly from the start point to the end point. Segmentation mode must also be enabled to use the
|
||||
#special lookahead buffer, tool-radius compensation, and kinematic-subroutine calculations.
|
||||
self.download(prg,mode=0,file='/tmp/coordTrf.cfg')
|
||||
|
||||
#set ct to:
|
||||
# 1 for simple linear transformation
|
||||
# 2 simple linear fwd/inv kinematics
|
||||
ct=0;
|
||||
if ct==1:
|
||||
#simple linear transformation
|
||||
prg = []
|
||||
prg.append('''
|
||||
//motors CX CZ RY FY
|
||||
// 4 5 3 1
|
||||
&1
|
||||
a
|
||||
#4->0
|
||||
#5->0
|
||||
#3->0
|
||||
#1->0
|
||||
|
||||
#4->X
|
||||
#5->Z
|
||||
#3->B
|
||||
#1->Y
|
||||
''')
|
||||
elif ct==2:
|
||||
#simple linear fwd/inv kinematics
|
||||
prg = []
|
||||
prg.append('''
|
||||
// Set the motors as inverse kinematic axes in CS 1
|
||||
//motors CX CZ RY FY
|
||||
// 4 5 3 1
|
||||
&1
|
||||
a
|
||||
#4->0
|
||||
#5->0
|
||||
#3->0
|
||||
#1->0
|
||||
|
||||
#4->I
|
||||
#5->I
|
||||
#3->I
|
||||
#1->I
|
||||
|
||||
open forward
|
||||
//define(KinVelEna='D0',KinAxisUsed='D0')
|
||||
define(qCX='L4', qCZ='L5', qW='L3', qFY='L1')
|
||||
define(DX='C6', DZ='C8', W='C1', Y='C7')
|
||||
//coord X Z B Y
|
||||
send 1"fwd_inp(%f) %f %f %f %f\\n",D0,qCX,qCZ,qW,qFY
|
||||
if(D0>0) callsub 100
|
||||
D0=$000001c2; //B=$2 X=$40 Y=$80 Z=$100 hex(2+int('40',16)+int('80',16)+int('100',16)) -> 0x1c2
|
||||
N100:
|
||||
DX=qCX
|
||||
DZ=qCZ
|
||||
W=qW
|
||||
Y=qFY
|
||||
send 1"fwd_res %f %f %f %f\\n",DX,DZ,W,Y
|
||||
P1001+=1
|
||||
close
|
||||
|
||||
open inverse
|
||||
//coord X Z B Y
|
||||
define( DX='C6' , DZ='C8' , W='C1', Y='C7')
|
||||
define(vDX='C38', vDZ='C40', vW='C33', vY='C39')
|
||||
|
||||
//motor q4 q5 q3 q1
|
||||
define( qCX='L4', qCZ='L5', qW='L3', qFY='L1')
|
||||
define(vqCX='R4', vqCZ='R5', vqW='R3', vqFY='R1')
|
||||
if(D0>0)
|
||||
send 1"inv_inp(%f) %f:%f %f:%f %f:%f %f:%f\\n",D0,DX,vDX,DZ,vDZ,W,vW,Y,vY
|
||||
else
|
||||
send 1"inv_inp(%f) %f %f %f %f\\n",D0,DX,DZ,W,Y
|
||||
|
||||
qCX=DX
|
||||
qCZ=DZ
|
||||
qW=W
|
||||
qFY=Y
|
||||
if(D0>0)
|
||||
{ // calculate velocities for PVT motion
|
||||
vqCX=vDX
|
||||
vqCZ=vDZ
|
||||
vqW=vW
|
||||
vqFY=vY
|
||||
send 1"inv_res %f:%f %f:%f %f:%f %f:%f\\n",qCX,vqCX,qCZ,vqCZ,qW,vqW,qFY,vqFY
|
||||
}
|
||||
else
|
||||
send 1"inv_res %f %f %f %f\\n",qCX,qCZ,qW,qFY
|
||||
|
||||
P1002+=1
|
||||
close
|
||||
''')
|
||||
|
||||
if self.args.verbose & 4:
|
||||
for ln in prg:
|
||||
print(ln)
|
||||
if file is not None:
|
||||
fh = open(file, 'w')
|
||||
fh.write('\n'.join(prg))
|
||||
fh.close()
|
||||
if host is not None:
|
||||
cmd = 'gpasciiCommander --host ' + host + ' ' + file
|
||||
print(cmd)
|
||||
p = sprc.Popen(cmd, shell=True) # , stdout=sprc.PIPE, stderr=sprc.STDOUT)
|
||||
# res=p.stdout.readlines(); print res
|
||||
retval = p.wait()
|
||||
# gather -u /var/ftp/gather/out.txt
|
||||
|
||||
def gen_prog(self,prgId=2,fnPrg=None,host=None,mode=0,**kwargs):
|
||||
def gen_prog(self,prgId=2,mode=0,**kwargs):
|
||||
'''
|
||||
kwargs:
|
||||
acq_per : acquire period: acquire data all acq_per servo loops (default=1)
|
||||
@@ -1052,22 +940,35 @@ close
|
||||
prg.append(' P1000=1')
|
||||
prg.append('close')
|
||||
prg.append('&1\nb%dr\n'%prgId)
|
||||
if self.args.verbose & 4:
|
||||
|
||||
self.download(prg,mode=3,file='/tmp/prg.cfg')
|
||||
|
||||
|
||||
def download(self,prg=None,mode=0,file='/tmp/helicalscan.cfg'):
|
||||
'''
|
||||
mode bits:
|
||||
bit 0 (1): wait execution finished (P1000==1)
|
||||
bit 1 (2): gather and save data
|
||||
bit 2 (4): ...
|
||||
'''
|
||||
host=self.args.host
|
||||
if prg is not None and self.args.verbose & 4:
|
||||
for ln in prg:
|
||||
print(ln)
|
||||
|
||||
if fnPrg is not None:
|
||||
fh=open(fnPrg,'w')
|
||||
if file is not None and prg is not None:
|
||||
fh=open(file,'w')
|
||||
fh.write('\n'.join(prg))
|
||||
fh.close()
|
||||
if host is not None:
|
||||
# ***download and start the program***
|
||||
cmd ='gpasciiCommander --host '+host+' '+ fnPrg
|
||||
print(cmd)
|
||||
p = sprc.Popen(cmd, shell=True)#, stdout=sprc.PIPE, stderr=sprc.STDOUT)
|
||||
#res=p.stdout.readlines(); print res
|
||||
retval = p.wait()
|
||||
if host is not None:
|
||||
# ***download and start the program***
|
||||
cmd ='gpasciiCommander --host '+host+' '+ file
|
||||
print(cmd)
|
||||
p = sprc.Popen(cmd, shell=True)#, stdout=sprc.PIPE, stderr=sprc.STDOUT)
|
||||
#res=p.stdout.readlines(); print res
|
||||
retval = p.wait()
|
||||
|
||||
if mode &1:
|
||||
# ***wait program finished P1000=1***
|
||||
com=GpasciiCommunicator().connect(host,prompt='# ')
|
||||
ack=GpasciiCommunicator.gpascii_ack
|
||||
@@ -1084,6 +985,7 @@ close
|
||||
#print val
|
||||
time.sleep(.2)
|
||||
sys.stdout.write('.');sys.stdout.flush()
|
||||
if mode &2:
|
||||
fnRmt = '/var/ftp/gather/out.txt'
|
||||
fnLoc = '/tmp/gather.txt'
|
||||
print('\ngather data to %s...' % fnRmt)
|
||||
@@ -1152,14 +1054,16 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n '
|
||||
|
||||
parser.add_option('-v', '--verbose', type="int", dest='verbose', help='verbosity bits (see below)', default=0)
|
||||
parser.add_option('-n', '--dryrun', action='store_true', help='dryrun to stdout')
|
||||
parser.add_option('--xy', action='store_true', help='sort x,y instead y,x')
|
||||
parser.add_option('--cfg', help='config file containing json configuration structure')
|
||||
parser.add_option('--host', help='hostname')
|
||||
|
||||
(args, other)=parser.parse_args()
|
||||
args.other=other
|
||||
|
||||
hs=HelicalScan(args)
|
||||
hs.args.verbose = 255
|
||||
hs.args.host='MOTTEST-CPPM-CRM0485'
|
||||
#SAR-CPPM-EXPMX1 MOTTEST-CPPM-CRM0485
|
||||
#hs.sequencer()
|
||||
#hs.test_find_rot_ctr()
|
||||
#hs.test_find_rot_ctr(n=5. ,per=1.,bias=2.31,ampl=4.12,phi=24.6)
|
||||
@@ -1169,20 +1073,19 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n '
|
||||
#hs.interactive_cx_cz_w_fy()
|
||||
#hs.interactive_dx_dz_w_y()
|
||||
|
||||
#SAR-CPPM-EXPMX1 MOTTEST-CPPM-CRM0485
|
||||
hs.gen_coord_trf_code('/tmp/helicalscan.cfg','MOTTEST-CPPM-CRM0485')
|
||||
#hs.gen_prog(file='/tmp/prg.cfg',host='MOTTEST-CPPM-CRM0485',mode=-1)
|
||||
#hs.gen_prog(fnPrg='/tmp/prg.cfg',host='MOTTEST-CPPM-CRM0485',mode=0,cntHor=1,cntVert=3,wRng=(120000,120000))
|
||||
#hs.gen_prog(fnPrg='/tmp/prg.cfg',host='MOTTEST-CPPM-CRM0485',mode=0,cntHor=1)
|
||||
#hs.gen_prog(fnPrg='/tmp/prg.cfg',host='MOTTEST-CPPM-CRM0485',mode=0)
|
||||
#hs.gen_prog(fnPrg='/tmp/prg.cfg',host='MOTTEST-CPPM-CRM0485',mode=0,cntHor=1,cntVert=5,wRng=(120000,120000))
|
||||
#hs.gen_prog(fnPrg='/tmp/prg.cfg',host='MOTTEST-CPPM-CRM0485',mode=1,cntHor=1,cntVert=5,wRng=(120000,120000),pt2pt_time=100)
|
||||
#hs.gen_prog(fnPrg='/tmp/prg.cfg',host='MOTTEST-CPPM-CRM0485',mode=1,cntHor=1,cntVert=5,wRng=(120000,120000),pt2pt_time=100,smt=0)
|
||||
#hs.gen_prog(fnPrg='/tmp/prg.cfg',host='MOTTEST-CPPM-CRM0485',mode=1,cntHor=1,cntVert=5,wRng=(0,360000))
|
||||
#hs.gen_prog(fnPrg='/tmp/prg.cfg',host='MOTTEST-CPPM-CRM0485',mode=1,cntHor=1,cntVert=5,wRng=(0,360000),smt=0)
|
||||
#hs.gen_prog(fnPrg='/tmp/prg.cfg',host='MOTTEST-CPPM-CRM0485',mode=1)
|
||||
hs.gen_prog(fnPrg='/tmp/prg.cfg',host='MOTTEST-CPPM-CRM0485',mode=1,
|
||||
pt2pt_time=100,cnt=1,cntVert=35,cntHor=7,hRng=(-.3,.3),wRng=(0,360000*3),yRng=(6.2,2.3))
|
||||
hs.download(file='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/cfg/sim_8_motors.cfg')
|
||||
hs.gen_coord_trf_code()
|
||||
#hs.gen_prog(mode=-1)
|
||||
#hs.gen_prog(mode=0,cntHor=1,cntVert=3,wRng=(120000,120000))
|
||||
#hs.gen_prog(mode=0,cntHor=1)
|
||||
#hs.gen_prog(mode=0)
|
||||
#hs.gen_prog(mode=0,cntHor=1,cntVert=5,wRng=(120000,120000))
|
||||
#hs.gen_prog(mode=1,cntHor=1,cntVert=5,wRng=(120000,120000),pt2pt_time=100)
|
||||
#hs.gen_prog(mode=1,cntHor=1,cntVert=5,wRng=(120000,120000),pt2pt_time=100,smt=0)
|
||||
#hs.gen_prog(mode=1,cntHor=1,cntVert=5,wRng=(0,360000))
|
||||
#hs.gen_prog(mode=1,cntHor=1,cntVert=5,wRng=(0,360000),smt=0)
|
||||
#hs.gen_prog(mode=1)
|
||||
hs.gen_prog(mode=1,pt2pt_time=100,cnt=1,cntVert=35,cntHor=7,hRng=(-.3,.3),wRng=(0,360000*3),yRng=(6.2,2.3))
|
||||
hs.load_rec()
|
||||
hs.show_pos();hs.show_vel()
|
||||
hs.interactive_anim()
|
||||
|
||||
Reference in New Issue
Block a user