import numpy as np
import dataAcquisitionMulti as datAc
import plotting as plo
import matplotlib.pyplot as plt

plt.close('all')

folderStr = "../simResults/44/160224/"
simValues = datAc.readStateFile(folderStr+"simStates.txt")
xTime = np.arange(0,4.95,0.05)
#simValues_nA = np.delete(simValues, np.s_[-1],1)
# plo.plotter2d((simValues,),("perfect",))
# plt.close('all')

##Direct input
plt.rcParams['text.latex.preamble']=[r"\usepackage{lmodern}"]
#Options
params = {'text.usetex' : True,
         'font.size' : 11,
         'font.family' : 'lmodern',
         'text.latex.unicode': True
#         'figure.autolayout': True
         }
plt.rcParams.update(params)

figHeight = 5
figWidth = 6.2

colorL = ['r','g','b','y']
styleL = ['solid','dashed','dotted','dash-dot']
cnt = 0
Ejemplo n.º 2
0
def printMeanVar(est, sim):
    namelist = ['unconstr Dip A: ', 'unconstr Cyl A:',  'constr Dip A: ', 'constr Cyl A:', ]
    cnt = 0
    for i in est:
        dif = sim-i
        mean = np.mean(np.linalg.norm(dif, axis=1))
        var = np.var(dif)**2
        print "%s %s +- %s" % (namelist[cnt], mean, var)
        # print "var of "+namelist[cnt], var

        cnt += 1


folderStr = "../simResults/24/160225/"
simValues = datAc.readStateFile(folderStr+"simStates.txt")

simValues_nA = np.delete(simValues, np.s_[3],1)
simValues_nA = np.delete(simValues_nA, np.s_[6],1)
# simValues_nA = np.delete(simValues_nA, np.s_[9],1)
# simValues_nA = np.delete(simValues_nA, np.s_[12],1)

loc = folderStr
print "witout ad-ab:"
uDip_nAt = datAc.readStateFile(loc+"estAng_dip0")
uCyl_nAt = datAc.readStateFile(loc+"estAng_cyl0")
cDip_nAt = datAc.readStateFile(loc+"estAng_dip1")
cCyl_nAt = datAc.readStateFile(loc+"estAng_cyl1")
# add dip...
uDip_nA = addDip(uDip_nAt)
uCyl_nA = addDip(uCyl_nAt)
    lineEst = mlines.Line2D([], [], color=colorL[1],
                      markersize=15, label='Estimated States')

    

    plt.figlegend((lineMCP,linePIP,lineDIP,linePHI,linePerf,lineEst),
                    (r'$\theta_{MCP}$',r'$\theta_{PIP}$',r'$\theta_{DIP}$',r'$\phi_{MCP}$', 'Perfect States', 'Estimated States'),
                    loc='center right',bbox_to_anchor=(0.9,1.05), ncol=3)

#    plt.subplots_adjust(top=0.8)    
    
    plt.savefig("../thesis/pictures/plots/difMult.png", dpi=300, bbox_inches='tight')
    return fig



folderStr = "../simResults/44/160224/"
simValues = datAc.readStateFile(folderStr+"simStates.txt")
simValues_nA = np.delete(simValues, np.s_[3],1)
simValues_nA = np.delete(simValues_nA, np.s_[6],1)
simValues_nA = np.delete(simValues_nA, np.s_[9],1)
simValues_nA = np.delete(simValues_nA, np.s_[12],1)

cCyl_A44 = datAc.readStateFile(folderStr+"estAng_cyl_A0")
#cCyl_A44 = addDip(cCyl_A44t)

#cCyl_nA12 = datAc.readStateFile("../simResults/12/160224/"+"estAng_cyl1")

plt.close('all')
pl = plotDif_sub([simValues, cCyl_A44])
Ejemplo n.º 4
0
# plotDif_ind(b,estCA, tMag, 'estCA 14')

""" for plotting least best result """
# sstring = "set5"
# estCA = datAc.readStateFile("../datasets/evalSets/estResults/160226_real/"+sstring+"_cylA14.txt")
# (tLeap,lInd,lMid,lRin,lPin) = datAc.readLeap("../datasets/evalSets/"+sstring+"_leap")
# (tMag,s1,s2,s3,s4) = datAc.readMag("../datasets/evalSets/"+sstring+"_mag")
# b = resampleLeap_point((tLeap,lInd), tMag)[0]
# b = b[:-1]
# tMag = tMag[:-1]
# plotDif_ind(b,estCA, tMag, 'estCA')
# plotDif(b,estCA, tMag, 'estCA')

""" for plotting 44 estimation... """
sstring = "set6"
estCA = datAc.readStateFile("../datasets/44/160210_" + sstring + "cylA44.txt")
(tLeap, lInd, lMid, lRin, lPin) = datAc.readLeap("../datasets/160210/160210_" + sstring + "_leap")
(tMag, s1, s2, s3, s4) = datAc.readMag("../datasets/160210/160210_" + sstring + "_mag")
(indRe, midRe, rinRe, pinRe) = resampleLeap_point((tLeap, lInd, lMid, lRin, lPin), tMag)

tMag = tMag[:-1]
# plotDif_ind(indRe[:-1],estCA[:,:4], tMag, 'estCA Index')
# plotDif_ind(rinRe[:-1],estCA[:,4:8], tMag, 'estCA Middle')
# plotDif_ind(midRe[:-1],estCA[:,8:12], tMag, 'estCA Ring')
# plotDif_ind(pinRe[:-1],estCA[:,12:], tMag, 'estCA Pinky')
# plotMulti([indRe[:-1],midRe[:-1]],estCA,tMag)

lIndN = np.linalg.norm(indRe, axis=1)
lMidN = np.linalg.norm(midRe, axis=1)
lRinN = np.linalg.norm(rinRe, axis=1)
lPinN = np.linalg.norm(pinRe, axis=1)
Ejemplo n.º 5
0
    # first
    bbox_image0 = BboxImage(
        Bbox([[lowerCorner[0], lowerCorner[1]], [upperCorner[0], upperCorner[1]]]),
        norm=None,
        origin=None,
        clip_on=False,
    )
    bbox_image0.set_data(imread("../thesis/pictures/statePics/bestLeap/out-0.jpg"))
    difP.add_artist(bbox_image0)
    # second
    lowC1 = difP.transData.transform((lowPos[0] + 6.5, lowPos[1]))
    upC1 = difP.transData.transform((upPos[0] + 6.5, upPos[1]))
    bbox_image1 = BboxImage(Bbox([[lowC1[0], lowC1[1]], [upC1[0], upC1[1]]]), norm=None, origin=None, clip_on=False)
    bbox_image1.set_data(imread("../thesis/pictures/statePics/bestLeap/out-5.jpg"))
    difP.add_artist(bbox_image1)

    plt.savefig("../thesis/pictures/plots/bestEstTEST.png", dpi=300, bbox_inches="tight")


plt.close("all")

""" for plotting best result """
sstring = "set4"
estCA = datAc.readStateFile("../datasets/evalSets/estResults/160217_real/" + sstring + "_cylA12.txt")
(tLeap, lInd, lMid, lRin, lPin) = datAc.readLeap("../datasets/evalSets/" + sstring + "_leap")
(tMag, s1, s2, s3, s4) = datAc.readMag("../datasets/evalSets/" + sstring + "_mag")
b = resampleLeap_point((tLeap, lInd), tMag)[0]
b = b[:-1]
tMag = tMag[:-1]
plotDif_ind(b, estCA, tMag, "estCA 14")