Example #1
0
def plotArticularPositions(what, foldername = "None", targetSize = "0.05"):
    rs = ReadSetupFile()
 
    if what == "CMAES":
        name = rs.CMAESpath + targetSize + "/" + foldername + "/Log/"
    elif what == "Brent":
        name = BrentTrajectoriesFolder
    else:
        name = rs.NNpath + foldername + "/Log/"

    state = getStateData(name)

    plt.figure(1, figsize=(16,9))
    for k,v in state.items():
        if rd.random()<0.06 or what != "Brent":
            Q1, Q2 = [], []
            for j in range(len(v)):
                Q1.append(v[j][2])
                Q2.append(v[j][3])
            plt.plot(Q1,Q2, c ='b')
    plt.xlabel("Q1 (rad)")
    plt.ylabel("Q2 (rad)")
    plt.title("Articular positions for " + what)
    plt.savefig("ImageBank/"+what+'_articular'+foldername+'.png', bbox_inches='tight')
    plt.show(block = True)
Example #2
0
def plotArticularPositions(what, foldername="None", targetSize="0.05"):
    rs = ReadSetupFile()

    if what == "CMAES":
        name = rs.CMAESpath + targetSize + "/" + foldername + "/Log/"
    elif what == "Brent":
        name = BrentTrajectoriesFolder
    else:
        name = rs.RBFNpath + foldername + "/Log/"

    state = getStateData(name)

    plt.figure(1, figsize=(16, 9))
    for k, v in state.items():
        if rd.random() < 0.06 or what != "Brent":
            Q1, Q2 = [], []
            for j in range(len(v)):
                Q1.append(v[j][2])
                Q2.append(v[j][3])
            plt.plot(Q1, Q2, c='b')
    plt.xlabel("Q1 (rad)")
    plt.ylabel("Q2 (rad)")
    plt.title("Articular positions for " + what)
    plt.savefig("ImageBank/" + what + '_articular' + foldername + '.png',
                bbox_inches='tight')
    plt.show(block=True)
Example #3
0
def plotArticularPositions(what, rs,foldername = "None"):
    plt.figure(1, figsize=(16,9))          
    if what == "OPTI":
        for i in range(len(rs.target_size)):
            ax = plt.subplot2grid((2,2), (i/2,i%2))
            name =  rs.OPTIpath + str(rs.target_size[i]) + "/" + foldername + "/Log/"
            state = getStateData(name)
            for _,v in state.items():
                Q1, Q2 = [], []
                for j in range(len(v)):
                    Q1.append(v[j][2])
                    Q2.append(v[j][3])
                ax.plot(Q1,Q2, c ='b')
            ax.set_xlabel("Q1 (rad)")
            ax.set_ylabel("Q2 (rad)")
            ax.set_title("Articular positions for " + str(rs.target_size[i]))
        imageFolder = rs.OPTIpath + "/ImageBank/"
    else :
        if what == "Brent":
            name = BrentTrajectoriesFolder
            imageFolder = "ImageBank/"
        else:
            name = rs.path + foldername + "/Log/"
            imageFolder = rs.path + "/ImageBank/"
    
        state = getStateData(name)
    

        for _,v in state.items():
            if rd.random()<0.06 or what != "Brent":
                Q1, Q2 = [], []
                for j in range(len(v)):
                    Q1.append(v[j][2])
                    Q2.append(v[j][3])
                plt.plot(Q1,Q2, c ='b')
        plt.xlabel("Q1 (rad)")
        plt.ylabel("Q2 (rad)")
        plt.title("Articular positions for " + what)
        
    checkIfFolderExists(imageFolder)   
    plt.savefig("ImageBank/"+what+'_articular'+foldername+'.svg', bbox_inches='tight')
    plt.show(block = True)
Example #4
0
def makeVelocityData(rs,arm,name,media):
    state = getStateData(name)
    factor = min(1, 100./len(state.items()))
    for k,v in state.items():
        index, speed = [], []
        if  rd.random()<factor:
            handxy = arm.mgdEndEffector([v[0][2],v[0][3]])
            distance = round(rs.getDistanceToTarget(handxy[0],handxy[1]),2)
            for j in range(len(v)):
                index.append(j*rs.dt)
                speed.append(arm.cartesianSpeed(v[j]))
            if distance<=0.15:
                media.plot(index, speed, c ='blue')
            elif distance<=0.28:
                media.plot(index, speed, c ='green')
            else:
                media.plot(index, speed, c ='red')
Example #5
0
def makeVelocityData(rs, arm, name, media):
    state = getStateData(name)
    factor = min(1, 100. / len(state.items()))
    for k, v in state.items():
        index, speed = [], []
        if rd.random() < factor:
            handxy = arm.mgdEndEffector([v[0][2], v[0][3]])
            distance = round(rs.getDistanceToTarget(handxy[0], handxy[1]), 2)
            for j in range(len(v)):
                index.append(j * rs.dt)
                speed.append(arm.cartesianSpeed(v[j]))
            if distance <= 0.15:
                media.plot(index, speed, c='blue')
            elif distance <= 0.28:
                media.plot(index, speed, c='green')
            else:
                media.plot(index, speed, c='red')