Beispiel #1
0
	def get_polyfit_to_data(self,x,y,n=3,draw=True):
		poly,inv_poly=m3tc.get_polyfit_to_data(x,y,n,draw)
		if (n==1):
			inv_poly2=[1/poly[0],-1*poly[1]/poly[0]]
			print 'Fit inv_poly of',inv_poly
			print 'Invert poly  of',inv_poly2
			inv_poly=inv_poly2
		return poly,inv_poly
	exit()
comp=m3f.create_component(name_ec)
proxy.subscribe_status(comp)
proxy.make_operational(name_ec)
q_log=[]
tq_log=[]
print 'Ready to generate motion? Hit any key to start'
m3t.get_keystroke()
ts=time.time()
try:
	while time.time()-ts>5.0:
		proxy.step()
		q=comp.status.qei_on
		tq=comp.status.adc_torque
		time.sleep(0.25)
		print 'DT',time.time()-ts, 'Q',q,'TQ',tq
		q_log.append(q)
		tq_log.append(tq)
except (KeyboardInterrupt,EOFError):
	proxy.stop()		

poly,inv_poly=m3tc.get_polyfit_to_data(q_log,tq_log,n=1)	
print 'Poly',poly
s=m3t.PolyEval(poly,log_tq)
m3t.mplot2(range(len(log_q)),log_load_mNm,s,xlabel='Samples',ylabel='Torque (mNm)',
			   y1name='loadcell',y2name='actuator')



		
Beispiel #3
0
comp = m3f.create_component(name_ec)
proxy.subscribe_status(comp)
proxy.make_operational(name_ec)
q_log = []
tq_log = []
print 'Ready to generate motion? Hit any key to start'
m3t.get_keystroke()
ts = time.time()
try:
    while time.time() - ts > 5.0:
        proxy.step()
        q = comp.status.qei_on
        tq = comp.status.adc_torque
        time.sleep(0.25)
        print 'DT', time.time() - ts, 'Q', q, 'TQ', tq
        q_log.append(q)
        tq_log.append(tq)
except (KeyboardInterrupt, EOFError):
    proxy.stop()

poly, inv_poly = m3tc.get_polyfit_to_data(q_log, tq_log, n=1)
print 'Poly', poly
s = m3t.PolyEval(poly, log_tq)
m3t.mplot2(range(len(log_q)),
           log_load_mNm,
           s,
           xlabel='Samples',
           ylabel='Torque (mNm)',
           y1name='loadcell',
           y2name='actuator')