work on tuning

This commit is contained in:
2018-11-08 14:23:43 +01:00
parent d7e0cf7764
commit 41a1fd3d38
7 changed files with 60 additions and 46 deletions

View File

@@ -335,8 +335,8 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n '
args=parser.parse_args()
#plt.ion()
args.host='MOTTEST-CPPM-CRM0573'
args.host=None
#args.host='MOTTEST-CPPM-CRM0573'
#args.host=None
if args.host is None:
comm=gt=None
else:
@@ -412,7 +412,8 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n '
elif mode == 6: # plot all raw acquired data files
# display bode plots
for fn in args.plot:
import glob
for fn in glob.glob(os.path.join(base,'*.npz')):
if os.path.basename(fn).startswith('sine_ol_mot'):
tune.bode_sine(openloop=True, file=fn)
if os.path.basename(fn).startswith('chirp_ol_mot'):
@@ -421,14 +422,33 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n '
tune.bode_sine(openloop=False, file=fn)
if os.path.basename(fn).startswith('chirp_cl_mot'):
tune.bode_chirp(openloop=False, file=fn)
print('done')
elif mode==7: #further tests
#tune.init_stage();
plt.close('all')
#tune.custom_chirp()
tune.custom_chirp(motor=1,minFrq=100,maxFrq=3000,amp=10,tSec=5,mode=0,file='/tmp/cst_chirp0.npz')
#tune.custom_chirp(motor=2,minFrq=1,maxFrq=1000,tSec=5,mode=1,file='/tmp/cst_chirp1.npz')
#tune.custom_chirp(motor=1,minFrq=1,maxFrq=3000,tSec=5,mode=2,file='/tmp/cst_chirp2.npz')
fn='/tmp/cst_chirp0.npz'
motLst=(1, 2)#(2,)#
init_stage=False
for mot in motLst:
fn=os.path.join(base, 'cst_chirp_s_ol_%d.npz' % mot)
if not init_stage and not os.path.isfile(fn):tune.init_stage();init_stage=True
tune.custom_chirp(motor=mot,minFrq=100,maxFrq=1000,amp=50,tSec=15,mode=0,file=fn)
init_stage=False
for mot in motLst:
fn=os.path.join(base, 'cst_chirp_s_cl1_%d.npz' % mot)
if not init_stage and not os.path.isfile(fn):tune.init_stage();init_stage=True
tune.custom_chirp(motor=mot,minFrq=1,maxFrq=100,amp=20,tSec=15,mode=1,file=fn)
init_stage=False
for mot in motLst:
fn=os.path.join(base, 'cst_chirp_s_cl2a_%d.npz' % mot)
if not init_stage and not os.path.isfile(fn):tune.init_stage();init_stage=True
tune.custom_chirp(motor=mot,minFrq=1,maxFrq=30,amp=100,tSec=30,mode=2,file=fn)
for mot in motLst:
fn=os.path.join(base, 'cst_chirp_s_cl2b_%d.npz' % mot)
if not init_stage and not os.path.isfile(fn):tune.init_stage();init_stage=True
tune.custom_chirp(motor=mot,minFrq=20,maxFrq=150,amp=10,tSec=30,mode=2,file=fn)
init_stage=False
for mot in motLst:
fn=os.path.join(base, 'cst_chirp_s_cl2c_%d.npz' % mot)
if not init_stage and not os.path.isfile(fn):tune.init_stage();init_stage=True
tune.custom_chirp(motor=mot,minFrq=100,maxFrq=300,amp=1,tSec=30,mode=2,file=fn)
elif mode==8: #generater code
#before this can be done, the observer controller has to be designed with matlab:
#s.a.ESB_MX/matlab/Readme.md
@@ -462,6 +482,15 @@ Examples:'''+''.join(map(lambda s:cmd+s, exampleCmd))+'\n '
fh.close()
print(fnc+' generated.')
print('now compile it looking at PBTools/pbtools/usr_servo_phase/usrServoSample')
elif mode==9: #SCRATCH
motLst=(1, 2)#(2,)#
init_stage=False
for mot in motLst:
fn=os.path.join(base, 'scratch_%d.npz' % mot)
if not init_stage and not os.path.isfile(fn):tune.init_stage();init_stage=True
tune.custom_chirp(motor=mot,minFrq=1,maxFrq=20,amp=200,tSec=15,mode=2,file=fn)
print('done')
plt.show()
#------------------ Main Code ----------------------------------
#ssh_test()'/tmp/usrcode.c'