Beispiel #1
0
#populate delta wave with sine and random noise
for i in range(0, np.size(t)):
    sim_sin[i] = sim_amp * np.sin(
        (np.pi / sim_phase) +
        (2 * np.pi / t_num) * t[i]) - sim_offset + np.random.randint(
            band_low, band_high)

#plot raw wave
plt.figure(1)
plt.plot(t, sim_sin, 'b1')

#build 2-D array for raw wave
raw_wave = np.column_stack((t, sim_sin))

#generate calibration wave
cal_wave = calibration_wave(wave=raw_wave, width=w_, sigma=sig_)

#generate filtered wave from calibration wave
#this filtered wave is a control case. the calibration routine is used
#on the original wave so the output should be (close to) 0.
new_wave = adjust_load(wave=raw_wave,
                       calibration_wave=cal_wave,
                       width=w_,
                       sigma=sig_)

plt.figure(2)
plt.plot(new_wave[:, 0], new_wave[:, 1], 'r1')

#initialize position (pos) and delta (load_sin) arrays
pos = np.arange(0, pos_num, pos_step, dtype=int)
load_sin = np.zeros(np.size(pos))
Beispiel #2
0
from processing_fxns import calibration_wave, adjust_load, plot_wave, moving_avg

plot_num = 0

sig = 2

def print_min_max(wave):
    w_min = min(wave[:,1])/(6.169445)
    w_max = max(wave[:,1])/(6.169445)
    print("Min: ", w_min)
    print("Max: ", w_max)
    band = w_min-w_max
    print("Band: ", band)
    
#calculate calibration wave from raw input
cal_wave = calibration_wave('P:/Motiv/1030_Robotics_Development_IRAD/02_Engineering/IRAD Actuator/Single_Axis_Testing/Testing_Data/Weighted_Testing_PosvsStrain/07272017_/unloaded/unloaded_125_0Hz_90to450_1.csv')
newx = cal_wave[:,0]
newy = cal_wave[:,1]
newstd = cal_wave[:,2]
cal_spos = np.column_stack((newx, newy+sig*newstd))
cal_sneg = np.column_stack((newx, newy-sig*newstd))

unloaded_wave = np.genfromtxt('P:/Motiv/1030_Robotics_Development_IRAD/02_Engineering/IRAD Actuator/Single_Axis_Testing/Testing_Data/Weighted_Testing_PosvsStrain/07272017_/unloaded/unloaded_125_0Hz_90to450_1_wtime.csv', delimiter=',', skip_header=True)

#filter the loaded data using the calibration curve
filtered_wave = adjust_load('P:/Motiv/1030_Robotics_Development_IRAD/02_Engineering/IRAD Actuator/Single_Axis_Testing/Testing_Data/Weighted_Testing_PosvsStrain/07272017_/20lbs/20lbs_125_0Hz_450to90_1.csv', cal_wave)

torque_wave = np.genfromtxt('P:/Motiv/1030_Robotics_Development_IRAD/02_Engineering/IRAD Actuator/Single_Axis_Testing/Testing_Data/Weighted_Testing_PosvsStrain/07272017_/20lbs/20lbs_125_0Hz_450to90_1_wtime.csv', delimiter=',', skip_header=True)
#torque_wave = torque_wave[:, [0,2]]
#torque_wave[:,1] = torque_wave[:,1]*(144.15/2048)
#smooth_wave = moving_avg(filtered_wave)
Beispiel #3
0
#populate delta wave with sine and random noise
for i in range(0, np.size(t)):
    sim_sin[i] = sim_amp * np.sin(
        (np.pi / sim_phase) +
        (2 * np.pi / t_num) * t[i]) - sim_offset + np.random.randint(
            band_low, band_high)

#plot raw wave
plt.figure(1)
plt.plot(t, sim_sin, 'b1')

#build 2-D array for raw wave
raw_wave = np.column_stack((t, sim_sin))

#generate calibration wave
cal_wave = calibration_wave(wave=raw_wave, width=w_, sigma=sig_)

#generate filtered wave from calibration wave
#this filtered wave is a control case. the calibration routine is used
#on the original wave so the output should be (close to) 0.
new_wave = adjust_load(wave=raw_wave,
                       calibration_wave=cal_wave,
                       width=w_,
                       sigma=sig_)

plt.figure(2)
plt.plot(new_wave[:, 0], new_wave[:, 1], 'r1')

#initialize position (pos) and delta (load_sin) arrays
pos = np.arange(0, pos_num, pos_step, dtype=int)
load_sin = np.zeros(np.size(pos))
f_2_5k = '08032017_/50Hz_0to3240000.csv'
f_200k = '08032017_/5kHz_200ks/5kHz_200ks_0_3520000.csv'


def print_min_max(wave):
    w_min = min(wave[:, 1])  #/(6.169445)
    w_max = max(wave[:, 1]) / (6.169445)
    print("Min: ", w_min)
    print("Max: ", w_max)
    band = w_min - w_max
    print("Band: ", band)


#import unloaded csv
raw_wave = np.genfromtxt(file_prefix + f_200k, delimiter=',', skip_header=True)
cal_wave = calibration_wave(raw_wave, width=w, sigma=sig)
#cal_wave = calibration_wave('C:/Users/trandhawa/Desktop/unloaded_125_0Hz_90to450_1.csv')
newx = cal_wave[:, 0]
newy = cal_wave[:, 1]
newstd = cal_wave[:, 2]
cal_spos = np.column_stack((newx, newy + sig * newstd))
cal_sneg = np.column_stack((newx, newy - sig * newstd))

#plot calibration wave from unloaded data
waves = [cal_wave, cal_spos, cal_sneg]
labels = ['Calibration_Wave', 'Calibration+2sig', 'Calibration-2sig']
markers = ['go', 'bo', 'ro']
scaling = [False, False, False]

plot_num += 1
file_prefix = 'P:/Motiv/1030_Robotics_Development_IRAD/02_Engineering/IRAD Actuator/Single_Axis_Testing/Testing_Data/Weighted_Testing_PosvsStrain/'
f_2_5k = '08032017_/50Hz_0to3240000.csv'
f_200k = '08032017_/5kHz_200ks/5kHz_200ks_0_3520000.csv'
plot_num = 0

wave_2_5k = np.genfromtxt(file_prefix + f_2_5k, delimiter = ',', skip_header=True)
wave = [wave_2_5k]
label =  ['2_5k_wave']
marker = ['b1']
scale = [False]

plot_num += 1
#plot_wave(wave, label, marker, plot_num, scale)
print_min_max(wave_2_5k)

cal_2_5k = calibration_wave(file_prefix + f_2_5k, width = w_)
wave = [cal_2_5k]
label =  ['cal_2_5k']
marker = ['b1']
scale = [False]

plot_num += 1
plot_wave(wave, label, marker, plot_num, scale)
print_min_max(cal_2_5k)

wave_200k = np.genfromtxt(file_prefix + f_200k, delimiter = ',', skip_header=True)
wave = [wave_200k]
label =  ['200k_wave']
marker = ['b1']
scale = [False]
    '/08022017_/varying_speed/calibration_50_0Hz_90to450_30ks_1.csv',
    delimiter=',',
    skip_header=True)
run_45 = np.genfromtxt(
    fname=file_prefix +
    '/08022017_/varying_speed/calibration_50_0Hz_90to450_45ks_1.csv',
    delimiter=',',
    skip_header=True)
run_100 = np.genfromtxt(
    fname=file_prefix +
    '/08022017_/varying_speed/calibration_125_0Hz_90to450_100ks_1.csv',
    delimiter=',',
    skip_header=True)

#Turn them into uniform arrays using the calibration function
calib_30 = calibration_wave(f_cal_30)
calib_45 = calibration_wave(f_cal_45)
calib_100 = calibration_wave(f_cal_100)

#Return the correlation coefficient for each set
corr_30_30 = np.corrcoef(calib_30[:, 1], calib_30[:, 1])
corr_30_45 = np.corrcoef(calib_30[:, 1], calib_45[:, 1])
corr_30_100 = np.corrcoef(calib_30[:, 1], calib_100[:, 1])
corr_45_45 = np.corrcoef(calib_45[:, 1], calib_45[:, 1])
corr_45_100 = np.corrcoef(calib_45[:, 1], calib_100[:, 1])
corr_100_100 = np.corrcoef(calib_100[:, 1], calib_100[:, 1])

print('30_30', corr_30_30)
print('30_45', corr_30_45)
print('30_100', corr_30_100)
print('45_45', corr_45_45)