def __init__(self): # Get activation signal a emg_data = load_data('./data/ta_vs_gait.csv') emg_data = np.array(emg_data) self.emg_function = get_norm_emg(emg_data) emg_sol_data = load_data('./data/soleus_vs_gait.csv') emg_sol_data = np.array(emg_sol_data) self.emg_sol_function = get_norm_sol(emg_sol_data) # Get ankle angle ankle_data = load_data('./data/ankle_vs_gait.csv') ankle_data = np.array(ankle_data) self.ankle_function = get_regress_ankle(ankle_data) # Get knee angle knee_data = load_data('./data/knee_vs_gait.csv') knee_data = np.array(knee_data) self.knee_function = get_regress_general(knee_data) # Get hip angle hip_data = load_data('./data/hip_vs_gait.csv') hip_data = np.array(hip_data) self.hip_function = get_regress_hip(hip_data) # Get shank velocity x = np.arange(0.0, 100.0, 1.0) shank_vel_data = 100 * derivative(self.knee_function, x, h=0.001) shank_vel_data = np.transpose(np.array([x, shank_vel_data])) self.shank_velocity_function = get_regress_general(shank_vel_data) # Get thigh velocity thigh_vel_data = 100 * derivative(self.hip_function, x, h=0.001) thigh_vel_data = np.transpose(np.array([x, thigh_vel_data])) self.thigh_velocity_function = get_regress_hip(thigh_vel_data)
for j in range(len(above_0_plot[0])): if above_0_plot[i][j] == 1: viable.append([ rmse_toe_height_plot[i][j], independent_1[i][j], independent_2[i][j] ]) # Sorts by first element (ie RMSE) top_viable = sorted(viable) if len(top_viable) >= 5: top_viable = top_viable[:5] # Find fatigues emg_data = load_data('./data/ta_vs_gait.csv') emg_data = np.array(emg_data) emg_function = get_norm_emg(emg_data) fatigues = [] all_fatigues = [] for i in range(len(top_viable)): a = Activation(top_viable[i][1], top_viable[i][2], scaling, non_linearity) a.get_activation_signal(emg_function) fatigues.append([a.get_fatigue(), i]) for i in range(len(viable)): a = Activation(viable[i][1], viable[i][2], scaling, non_linearity) a.get_activation_signal(emg_function) all_fatigues.append([a.get_fatigue(), i]) # Sorts by first element (ie fatigue)
if __name__ == '__main__': plot_curves( ) # plot CE,SE,PE force-length curves and CE force-velocity curve print(get_velocity(1.0, np.array([1.0]), np.array( [1.01]))) # calculate velocity given a=1.0,lm=1.0,ls=1.01 # Constants max_isometric_force = 605.0 total_length = 0.44479194718764087 resting_muscle_length = .25 * total_length resting_tendon_length = .75 * total_length emg_data = load_data('./data/ta_vs_gait.csv') emg_data = np.array(emg_data) emg_data_regress = get_norm_emg(emg_data) frequency, duty_cycle, scaling, non_linearity = 35, 0.5, 1, -1 a = Activation(frequency, duty_cycle, scaling, non_linearity) a.get_activation_signal(emg_data_regress, shape="monophasic") # Create an HillTypeMuscle using the given constants muscle = HillTypeMuscle(max_isometric_force, resting_muscle_length, resting_tendon_length) # Dynamic equation def f(t, x): normalized_tendon_length = muscle.norm_tendon_length(total_length, x) temp = get_velocity(a.get_amp(t / 100), np.array([x]), np.array([normalized_tendon_length])) return temp