def _main(): fileName = 'Subject005Trial08.txt' forcePlateNames = ['FP1'] footMarkerNames = ['RHEE', 'RMT5'] forceData = Question1.parsePointFile(fileName, forcePlateNames, suffix='ForX') momentData = Question1.parsePointFile(fileName, forcePlateNames, suffix='MomX') copData = Question1.parsePointFile(fileName, forcePlateNames, suffix='CopX') markerData = Question1.parsePointFile(fileName, footMarkerNames) xCoords = np.zeros(400) zCoords = np.zeros_like(xCoords) yTorques = np.zeros_like(xCoords) for i, frame in enumerate(range(600,1000)): xCoords[i], zCoords[i], yTorques[i] = calcualteCop(forceData['FP1'][frame], momentData['FP1'][frame]) # print xCoord, copData['FP1'][i,0], zCoord, copData['FP1'][i,2], yTorque plt.style.use('/home/will/Projects/MCLS_CSU/MCLS_Res/GeneralTools/Visualization/matplotlibStyleSheets/MCLSPoster') fig, ax = plt.subplots(nrows=3) xVals = np.arange(600, 1000)*0.01 ax[0].plot(xVals, xCoords, color='g', linewidth=2) ax[1].plot(xVals, zCoords, color='r', linewidth=2) ax[2].plot(xVals, yTorques, color='b', linewidth=2) ax[0].set_ylabel(r'$COP_x$') ax[1].set_ylabel(r'$COP_z$') ax[2].set_ylabel(r'$T_y$') ax[2].set_xlabel('Time (s)') for i in range(3): ax[i].grid() ax[i].set_ylim(0,1) ax[2].set_ylim(-4,4) fig2, ax2 = plt.subplots(nrows=1) copx = ax2.plot(xVals, xCoords, color='g', linewidth=2) rhee = ax2.plot(xVals, markerData['RHEE'][600:1000,0], color='c', linewidth=2.5) rmt = ax2.plot(xVals, markerData['RMT5'][600:1000,0], color='m', linewidth=2.5) ax2.set_xlabel('Time (s)') ax2.set_ylabel(r'$COP_x, Marker_x$') ax2.set_ylim(0,1) ax2.grid() fig2.legend([copx[0], rhee[0], rmt[0]], (r'$COP_x$', 'RHEE', 'RMT5'), loc='upper center', ncol=3, borderpad=0.4, numpoints=2, columnspacing=0.5) plt.show()
def _main(): # Define the file that contains the data, the desired range of frames, and the marker names that will be used. fileName = 'Subject005Trial08.txt' frames = range(600, 1000) desiredPointNames3 = ['RGTRO', 'RHEE', 'RMT5'] desiredPointNames5 = ['RGTRO', 'RLEK', 'RLM', 'RHEE', 'RMT5'] # Parse the marker data, and define the number of frames and number of markers marker3Data = Question1.parsePointFile(fileName, desiredPointNames3) marker5Data = Question1.parsePointFile(fileName, desiredPointNames5) frameNumber = len(frames) # Define the leg model femurLength = 0.46 # m shankLength = 0.41 # m footLength = 0.20 # m femurAxis = np.array([0.0, -1]) shankAxis = np.array([0.0, -1]) footAxis = np.array([1, 0.0]) femurBody = BodySegment(femurLength, femurAxis) shankBody = BodySegment(shankLength, shankAxis) footBody = BodySegment(footLength, footAxis) bodySegments = [femurBody, shankBody, footBody] initialGuess = np.array([0.38, 0.84, 40.0, -60.0, 0.0])#np.zeros(5) marker3Results = run3MarkerForwardKinematics(marker3Data, bodySegments, frameNumber, frames, initialGuess) marker5Results = run5MarkerForwardKinematics(marker5Data, bodySegments, frameNumber, frames, initialGuess) print 'Tx = ', min(marker3Results[:,0]), max(marker3Results[:,0]) print 'Ty = ', min(marker3Results[:,1]), max(marker3Results[:,1]) print 'hip = ', min(marker3Results[:,2]), max(marker3Results[:,2]) print 'knee = ', min(marker3Results[:,3]), max(marker3Results[:,3]) print 'foot = ', min(marker3Results[:,4]), max(marker3Results[:,4]) plotGeneralizedCoordinates([marker3Results, marker5Results]) return