Compare commits
4 Commits
64bd6f79f5
...
890daa9702
Author | SHA1 | Date |
---|---|---|
interfisch | 890daa9702 | |
interfisch | a68df6afab | |
interfisch | 16dfabc6ba | |
interfisch | e31ccb1813 |
|
@ -112,7 +112,7 @@ void led_update(unsigned long loopmillis,ESCSerialComm& escFront, ESCSerialComm&
|
|||
if (loopmillis-last_notidle>5000) {
|
||||
//Standing
|
||||
float vbat=min(escRear.getFeedback_batVoltage(),escFront.getFeedback_batVoltage());
|
||||
led_gauge(loopmillis,vbat,3*12,4.2*12,strip.Color(0, 255, 0, 0),strip.Color(100, 0, 0, 0));
|
||||
led_gauge(loopmillis,vbat,3.3*12,4.2*12,strip.Color(0, 255, 0, 0),strip.Color(100, 0, 0, 0));
|
||||
}else{
|
||||
//Driving
|
||||
float currentMean=escRear.getFiltered_curL()+escRear.getFiltered_curR()+escFront.getFiltered_curL()+escFront.getFiltered_curR();
|
||||
|
|
|
@ -81,7 +81,7 @@ bool initLogging() {
|
|||
|
||||
void loggingLoop(unsigned long loopmillis,ESCSerialComm& escFront, ESCSerialComm& escRear) {
|
||||
|
||||
static unsigned long last_datalogging_write=0;
|
||||
static unsigned long last_datalogging_write=loopmillis; //initialize with current time to have first log written after one interval
|
||||
static boolean logging_headerWritten=false;
|
||||
|
||||
unsigned long logginginterval=LOGGINGINTERVAL;
|
||||
|
|
|
@ -269,14 +269,6 @@ void loop() {
|
|||
|
||||
|
||||
|
||||
loggingLoop(loopmillis,escFront,escRear);
|
||||
if (!armed && !statswritten) { //write stats only once when disarmed
|
||||
statswritten=true;
|
||||
writeTrip(loopmillis,escFront,escRear);
|
||||
}
|
||||
if (statswritten && armed) {
|
||||
statswritten=false;
|
||||
}
|
||||
|
||||
leds();
|
||||
led_update(loopmillis,escFront,escRear); //ws2812 led ring
|
||||
|
@ -327,6 +319,17 @@ void loop() {
|
|||
serialCommandLoop(loopmillis,escFront,escRear);
|
||||
|
||||
|
||||
//Logging
|
||||
loggingLoop(loopmillis,escFront,escRear);
|
||||
if (!armed && !statswritten) { //write stats only once when disarmed
|
||||
statswritten=true;
|
||||
writeTrip(loopmillis,escFront,escRear);
|
||||
}
|
||||
if (statswritten && armed) {
|
||||
statswritten=false;
|
||||
}
|
||||
|
||||
|
||||
looptime_duration_min=min(looptime_duration_min,millis()-loopmillis);
|
||||
looptime_duration_max=max(looptime_duration_max,millis()-loopmillis);
|
||||
|
||||
|
|
|
@ -1,52 +1,47 @@
|
|||
import matplotlib.pyplot as plt
|
||||
import csv
|
||||
#import csv
|
||||
import pandas as pd
|
||||
|
||||
x=[]
|
||||
speed_FrontL=[]
|
||||
speed_FrontR=[]
|
||||
speed_RearL=[]
|
||||
speed_RearR=[]
|
||||
|
||||
fp = open('LOG00203c_replacedFrontLeftWheel.TXT')
|
||||
|
||||
rdr = csv.DictReader(filter(lambda row: row[0]!='#', fp))
|
||||
for row in rdr:
|
||||
#print(row)
|
||||
x.append(float(row['cmd_FrontL']))
|
||||
|
||||
speed_FrontL.append(float(row['speed_FrontL']))
|
||||
speed_FrontR.append(float(row['speed_FrontR']))
|
||||
speed_RearL.append(float(row['speed_RearL']))
|
||||
speed_RearR.append(float(row['speed_RearR']))
|
||||
fp.close()
|
||||
import numpy as np
|
||||
|
||||
|
||||
#plt.plot(x,y, label='Loaded from file!')
|
||||
scattersize=5
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description='Analyzes fixed csv logs from bobbycar')
|
||||
parser.add_argument('-i', '--input', type=argparse.FileType('r'), required=True, help="input csv log file")
|
||||
args = parser.parse_args()
|
||||
|
||||
df = pd.read_csv(args.input.name)
|
||||
|
||||
x = df['timestamp']
|
||||
x = [i-x[0] for i in x] #offset time by starttime
|
||||
|
||||
|
||||
scattersize=1
|
||||
scatteralpha=0.1
|
||||
plt.scatter(x,speed_FrontL, s=scattersize, alpha=scatteralpha, label="speed_FrontL")
|
||||
plt.scatter(x,speed_FrontR, s=scattersize, alpha=scatteralpha, label="speed_FrontR")
|
||||
plt.scatter(x,speed_RearL, s=scattersize, alpha=scatteralpha, label="speed_RearL")
|
||||
plt.scatter(x,speed_RearR, s=scattersize, alpha=scatteralpha, label="speed_RearR")
|
||||
plt.xlabel('cmd')
|
||||
plt.ylabel('speed')
|
||||
plt.title('Interesting Graph\nCheck it out')
|
||||
plt.legend()
|
||||
|
||||
|
||||
fig, ax1 = plt.subplots()
|
||||
|
||||
ax2 = ax1.twinx()
|
||||
|
||||
|
||||
#plt.scatter(x,df['rpm_FrontL'], s=scattersize, alpha=scatteralpha, label="rpm_FrontL")
|
||||
ax1.plot(x,np.array(df['vbat_Front']), c='b', alpha=0.5, label="vbat_Front")
|
||||
ax1.plot(x,np.array(df['vbat_Rear']), c='r', alpha=0.5, label="vbat_Rear")
|
||||
ax2.plot(x,np.array(df['cmd_FrontL']), c='r', alpha=0.5, label="cmd_FrontL")
|
||||
#plt.plot(x,np.array(df['currentConsumed']), c='g', alpha=0.5, label="currentConsumed")
|
||||
|
||||
#plt.scatter(x,df['rpm_FrontR'], s=scattersize, alpha=scatteralpha, label="rpm_FrontR")
|
||||
|
||||
ax1.set_xlabel('timestamp')
|
||||
#plt.ylabel('data')
|
||||
ax1.set_ylabel('first axis')
|
||||
ax2.set_ylabel('second axis')
|
||||
#plt.title('')
|
||||
ax1.legend(loc='upper left')
|
||||
ax2.legend(loc='upper right')
|
||||
plt.show()
|
||||
|
||||
|
||||
'''
|
||||
with open(,'r') as csvfile:
|
||||
plots = csv.reader(filter(lambda row: row[0]!='#', csvfile), delimiter=',')
|
||||
for row in plots:
|
||||
x.append(float(row[0]))
|
||||
y.append(float(row[1]))
|
||||
|
||||
plt.plot(x,y, label='Loaded from file!')
|
||||
plt.xlabel('x')
|
||||
plt.ylabel('y')
|
||||
plt.title('Interesting Graph\nCheck it out')
|
||||
plt.legend()
|
||||
plt.show()
|
||||
'''
|
||||
|
||||
exit()
|
||||
|
|
|
@ -148,6 +148,8 @@ def delete_file(filename):
|
|||
exit()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if serialport.isOpen():
|
||||
|
||||
establish_connection()
|
||||
|
@ -159,6 +161,7 @@ if serialport.isOpen():
|
|||
|
||||
|
||||
#Copy all Files
|
||||
|
||||
failed=0
|
||||
|
||||
for filename in filenames:
|
||||
|
@ -180,6 +183,7 @@ if serialport.isOpen():
|
|||
|
||||
|
||||
#Delete all files
|
||||
|
||||
'''
|
||||
log_off()
|
||||
for filename in filenames:
|
||||
|
@ -187,12 +191,7 @@ if serialport.isOpen():
|
|||
'''
|
||||
|
||||
|
||||
|
||||
|
||||
serialport.write("echo on\n".encode())
|
||||
|
||||
|
||||
|
||||
|
||||
serialport.close()
|
||||
|
||||
|
|
|
@ -107,8 +107,6 @@ if (args.consecutive):
|
|||
|
||||
|
||||
|
||||
print("")
|
||||
print(inputFilenames)
|
||||
|
||||
|
||||
else:
|
||||
|
@ -150,7 +148,7 @@ for inputFilename in inputFilenames:
|
|||
|
||||
linesStarttime+=_linesStarttime
|
||||
|
||||
print("Line in file="+str(len(inputlines)))
|
||||
print("Lines in file="+str(len(inputlines)))
|
||||
|
||||
assert len(lines)==len(linesStarttime), "Length of lines and linesStarttime does not match"
|
||||
|
||||
|
|
Loading…
Reference in New Issue