Esempio n. 1
0
            print('Header incorrect, starting a new file.')
            csv_file = open(path2csv, 'w')
            writer = csv.writer(csv_file)
            writer.writerow(
                ['Log File', 'Acc score', 'Peak score', 'HF score'])
    except IOError:
        print(f'{path2csv} cannot be read. Creating a new one.')
        csv_file = open(path2csv, 'w')
        writer = csv.writer(csv_file)
        writer.writerow(['Log File', 'Acc score', 'Peak score', 'HF score'])
    finally:
        writer.writerow([
            log_file, scores['acc_score'], scores['peak_score'],
            scores['hf_score']
        ])


# path constructor
log_path = '/home/lucas/Documents/Log_Analysis/Logs'
files = os.listdir(log_path)

for file in files:
    log_file = f'{log_path}/{file}'
    print(log_file)
    try:
        info = logextract(log_file, topic_list)
        scores = logscore(info)
        addscore(log_file, scores)
    except LogError:
        print(f'{log_file} is not relevant. Discarded.')
        continue
Esempio n. 2
0
import sys
sys.path.append('/Users/lucas/Documents/Travail/Yuneec/LogAnalysis')
from analog import logextract
import csv

# path = '/home/lucas/Documents/Travail/Yuneec/Logs/Snow Orange (Battery 9) z0=1/log_195_2019-9-26-14-05-18.ulg'
path = '/home/lucas/Documents/Log_Analysis/Logs/Snow Orange (Battery 9) z0=1/log_195_2019-9-26-14-05-18.ulg'
info = logextract(path,'battery_status')
u = info['battery_current']
y = info['battery_voltage']
t = info['time_bs']

csv_file = open('Battery 9/log_195.csv','w')
writer = csv.writer(csv_file)

writer.writerow(['u','y','t'])
for k in range(len(u)):
    writer.writerow([u[k],y[k],t[k]])

Esempio n. 3
0
import numpy as np
import sys
sys.path.append('/home/lucas/Documents/Log_Analysis/Battery')
sys.path.append('/Users/Lucas/Documents/Travail/Yuneec/LogAnalysis')
import analog
import matplotlib.pyplot as plt

#%%
import platform
if platform.system() == 'Linux':
    folder = '/home/lucas/Documents/Log_Analysis/Logs/Snow Orange (Battery 9) z0=1'
if platform.system() == 'Darwin':
    folder = '/Users/Lucas/Documents/Travail/Yuneec/Logs/Snow Orange (Battery 9) z0=1'
log_file = analog.pathfromQGC(folder, index=195)
info = analog.logextract(log_file, 'battery_status')

#%%
u = info['battery_current']
u = np.reshape(u, (len(u), 1))
print(np.shape(u))
t = info['time_bs']
y = info['battery_voltage'] / 4
y = np.reshape(y, (len(y), 1))
print(np.shape(y))

#%%
u = u[t > 60]
y = y[t > 60]
t = t[t > 60]

#%%
Esempio n. 4
0
from analog import logextract as logextract, logscore as logscore, sixaxes_spectrum as sixaxes_spectrum


### TO BE  DEFINED BY USER ###

gazebopath = '/home/lucas/src/px4/Firmware/build/px4_sitl_default/tmp/rootfs/log'

# 1. Enter the path to the log file to be anaylzed here.
log_file = analog.pathfromQGC('/home/lucas/Documents/Log_Analysis/Logs',index,date,time)

# 2. Enter the path where the figures should be saved here.
savedir = f'/home/lucas/Documents/Log_Analysis/Vibrations/Figures/{log_date}'

### NO NEED TO MODIFY CODE AFTER THIS LINE ###

info = logextract(log_file)

time_sc = info['time_sc'] # already in s
time_ao = info['time_ao'] 
acc_x=info['acc_x']
acc_y=info['acc_y']
acc_z=info['acc_z']
roll = info['roll']
pitch = info['pitch']
yaw = info['yaw']
rpm = info['rpm']

# a reasonable threshold for strong vibration is anything with a peak-to-peak of more than 2-3 m/s/s 
# (http://docs.px4.io/master/en/log/flight_log_analysis.html)

threshold = 1.5 # m/s^2, should be 3 peak to peak
Esempio n. 5
0
 def iofromlog(self):
     info = logextract(self.logfile, 'battery_status')
     y = info['battery_voltage']
     u = info['battery_current']
     return y, u
Esempio n. 6
0
# Test with polynomial curve
p = np.polyfit(curve.SOC, curve.OCV, 11)

# define logs to optimize on
folder = '/home/lucas/Documents/Log_Analysis/Logs/Snow Orange (Battery 9) z0=1'
#folder ='/Users/Lucas/Documents/Travail/Yuneec/Logs/Snow Orange (Battery 9) z0=1'
files = os.listdir(folder)

time = np.array([])
current = np.array([])
voltage = np.array([])
tstoplist = [0]

for file in sorted(files):
    print(file)
    info = analog.logextract(f'{folder}/{file}', 'battery_status')
    time = np.append(time,
                     info['time_bs'] - info['time_bs'][0] + tstoplist[-1])
    tstoplist.append(time[-1])
    current = np.append(current, info['battery_current'])
    voltage = np.append(voltage, info['battery_voltage'] / 4)

n = len(current)

# initial guess
ECparams = pd.read_csv('ECparams.csv')
x0 = np.array([ECparams['R0'], ECparams['R1'], ECparams['C1']])
initbat = battery.Thevenin(z0, Q, curve, ECparams['R0'], ECparams['R1'],
                           ECparams['C1'])
vsim = initbat.simulate(time, current, curve)
#x0 = np.append(x0,initbat.simz)