Ejemplo n.º 1
0
def firstStep(indAnt, curve, vel, isFlat=True, ground=None):
    """Initialise the simulation
    
    This function initialises the settings at the beginning of the simulation.
    
    """
    speed = np.linalg.norm(vel)
    curveStartPoint = up.getPosCurvePoint(curve, 0.01)
    tan = up.getTanCurvePoint(curve, 0.01)
    yAngle = up.getAngle(tan)
    
    comTrajList = []
    comTrajList.append(curveStartPoint)    
       
    triList = []
    newTri = tr.createNewTriTemplate(curveStartPoint, True, yRot=yAngle)    
    newTri = tr.plotTri(newTri, isFlat=isFlat, ground=ground)
    triList.append(newTri)

    
    strideLen = tr.triangleSpeed(speed)
    newTri = tr.createNewTriTemplate(curveStartPoint + strideLen/2*tan, False, yRot=yAngle)    
    newTri = tr.plotTri(newTri, isFlat=isFlat, ground=ground)
    triList.append(newTri)    
    
    diffCOM = np.average(triList[1], 0) - np.average(triList[0], 0)
    curTriRight = triList[1] - diffCOM    
    up.animateBodyLeg(indAnt, curveStartPoint, up.mergeTwoTripod(triList[0], curTriRight))    
    
    jointLTList = []
    jointRTList = []
    jointLT, jointRT = fe.solveJointAngles(curveStartPoint + [0, 0, -0.1], triList[0], triList[1], True)    
    jointLTList.append(jointLT)
    jointRTList.append(jointRT)        
    return comTrajList, triList, jointLTList, jointRTList
Ejemplo n.º 2
0
def computePeriod(speed):
    """Compute the period, given the speed
    
    """
    strideLen = tr.triangleSpeed(speed)
    if speed == 0:
        T = strideLen/0.001
    else:
        T = strideLen/speed
    return T
Ejemplo n.º 3
0
def estimateNextTri(curTri, nextTri, speed):
    """Estimate the triangle vertices 
    
    arguments:  
    
    - curTri  -- current triangle vertices. 3x1 numpy array
    - nextTri -- next triangle vertices. 3x1 numpy array
    - speed   -- locomotion speed. scalar
    
    return:    
    
    - estNextTri -- the estimated vertices for next triangle. 3x1 numpy array
    
    """
    strideLen = tr.triangleSpeed(speed)
    diffVec = np.average(nextTri, axis=0) - np.average(curTri, axis=0)
    strideVec = diffVec/np.linalg.norm(diffVec)*strideLen
    estNextTri = curTri + strideVec
    return estNextTri