Ejemplo n.º 1
0
    def test_manipulate():
        x_draw_range = (-2, 2)
        y_draw_range = (-2, 2)

        plot = ymp.SmartPlot()
        plot.setXlimit(x_draw_range[0], x_draw_range[1])
        plot.setYlimit(y_draw_range[0], y_draw_range[1])
        X = pe.frange(x_draw_range[0], x_draw_range[1], .01)
        plot.setXdata('frames', X)

        #        x_range = (0,1); y_range = (0,1)
        #        plot.addYdata('translate', map(translate(sine, .1, .1), X))
        #        plot.addYdata('domain', map(domain(sine, [.2, .7]), X))
        #        plot.addYdata('translate * domain', map(translate(domain(sine, [.0, .5]), .1, .1), X))

        x_range = (0, 1)
        y_range = (0, 1)
        plot.addYdata(
            'concatenate',
            map(concatenate([zero, hermite2nd, one], [1 / 3., 2 / 3.]), X))

        #        x_range = (0,2); y_range = (0,.5)
        #        plot.addYdata('scale', map(scale(sine, x_range, y_range), X))
        ##        plot.addYdata('domain', map(domain(sine, x_range), X))

        #        x_range = (0,1); y_range = (0,1)
        #        plot.addYdata('hermite2nd', map(hermite2nd, X))
        #        plot.addYdata('mirror', map(mirror(hermite2nd, .5, .0), X))
        #        plot.addYdata('mirror2', map(mirror(hermite2nd, None, .0), X))
        #        plot.addYdata('mirror3', map(mirror(hermite2nd, .5, None), X))

        plot.addXspans('x_range', [x_range])
        plot.addYspans('y_range', [y_range])
        plot.show()
Ejemplo n.º 2
0
    def test_getBipedGaitStates():
        bvhFilePath = '../samples/wd2_WalkSameSame00.bvh'
        motion = yf.readBvhFile(bvhFilePath, .01)
        
        hRef = .1; vRef = .3
        lc = yma.getElementContactStates(motion, motion[0].skeleton.getElementIndex('LeftFoot'), hRef, vRef)
        rc = yma.getElementContactStates(motion, motion[0].skeleton.getElementIndex('RightFoot'), hRef, vRef)

        rawStateList = getBipedGaitStates(lc, rc)
        cookedStateList = getBipedGaitStates(lc, rc, 10, 1.)
        
        intervals, types = yma.states2intervals(cookedStateList)
        for i in range(len(intervals)):
            print(intervals[i], GaitState.text[types[i]])

        print()
        print([yma.intIntervalUp(int) for int in intervals])
        print(getWalkingSteps(lc, rc, True))
        print(getBipedGaitIntervals(lc, rc, 10, 1.))
        
        plot = ymp.SmartPlot()
        plot.setXdata('frame', range(len(motion)))
        plot.addYdata('rawState', rawStateList)
        plot.addYdata('cookedState', cookedStateList)
        plot.showModeless()
        
        viewer = ysv.SimpleViewer()
        viewer.record(False)
        viewer.doc.addRenderer('motion', yr.JointMotionRenderer(motion, (0,0,255), yr.LINK_LINE))
        viewer.doc.addObject('motion', motion)
        viewer.startTimer(1/30.)
        viewer.show()
        Fl.run()
Ejemplo n.º 3
0
    def test_graph_functions():
        x_draw_range = (0, 1)
        y_draw_range = (0, 1)

        plot = ymp.SmartPlot()
        plot.setXlimit(x_draw_range[0], x_draw_range[1])
        plot.setYlimit(y_draw_range[0], y_draw_range[1])

        X = pe.frange(x_draw_range[0], x_draw_range[1], .01)
        plot.setXdata('frames', X)

        plot.addYdata('identity', map(identity, X))
        plot.addYdata('hermite2nd', map(hermite2nd, X))
        plot.addYdata('halfsine', map(halfsine, X))
        plot.addYdata('halfsineextended2',
                      map(concatenate([zero, halfsine, one], [.25, .75]), X))
        plot.addYdata('sine', map(sine, X))
        plot.addYdata('zero', map(zero, X))
        plot.addYdata('H1', map(H1, X))
        plot.addYdata('H2', map(H2, X))
        plot.addYdata('H3', map(H3, X))

        plot.show()
Ejemplo n.º 4
0
     endSeg = len(intervals)-2
     mean_CM_vel = sum(CM_vels[startSeg:endSeg+1]) / (endSeg - startSeg + 1)
     mean_stepLength = sum(stepLengths[startSeg:endSeg+1]) / (endSeg - startSeg + 1)
     mean_stepDuration = sum(stepDurations[startSeg:endSeg+1]) / (endSeg - startSeg + 1)
     print('mean (%dth~%dth)         %10.2f %10.2f %10.2f'%(startSeg, endSeg, mean_CM_vel, mean_stepLength, mean_stepDuration))
     print()
 
 
     if VISUALIZE:
         #===============================================================================
         # plotting
         #===============================================================================
         rawStates = yba.getBipedGaitStates(lc, rc)
         refinedStates = yba.getBipedGaitStates(lc, rc, jumpThreshold, jumpBias, stopThreshold, stopBias)
         
         plot = ymp.SmartPlot()
         plot.setXdata('frame', list(range(len(motion))))
         plot.addYdata('rawStates', rawStates)
         plot.addYdata('refinedStates', refinedStates)
         plot.showModeless()
         
         #===============================================================================
         # viewer
         #===============================================================================
         viewer = ysv.SimpleViewer()
         viewer.record(False)
         viewer.doc.addRenderer('ys_motion', yr.JointMotionRenderer(motion, (0,100,255), yr.LINK_LINE))
         viewer.doc.addObject('ys_motion', motion)
 #        viewer.doc.addRenderer('motionModel', cvr.VpModelRenderer(motionModel, (0,100,255), yr.POLYGON_LINE))
         
         def postFrameCallback_Always(frame):