Compare commits

..

No commits in common. "890daa97025f55e0ac01be9f92c2021d8bd9c16a" and "64bd6f79f5d0900145f31d759073c9427752c581" have entirely different histories.

6 changed files with 97 additions and 92 deletions

View File

@ -112,7 +112,7 @@ void led_update(unsigned long loopmillis,ESCSerialComm& escFront, ESCSerialComm&
if (loopmillis-last_notidle>5000) { if (loopmillis-last_notidle>5000) {
//Standing //Standing
float vbat=min(escRear.getFeedback_batVoltage(),escFront.getFeedback_batVoltage()); float vbat=min(escRear.getFeedback_batVoltage(),escFront.getFeedback_batVoltage());
led_gauge(loopmillis,vbat,3.3*12,4.2*12,strip.Color(0, 255, 0, 0),strip.Color(100, 0, 0, 0)); led_gauge(loopmillis,vbat,3*12,4.2*12,strip.Color(0, 255, 0, 0),strip.Color(100, 0, 0, 0));
}else{ }else{
//Driving //Driving
float currentMean=escRear.getFiltered_curL()+escRear.getFiltered_curR()+escFront.getFiltered_curL()+escFront.getFiltered_curR(); float currentMean=escRear.getFiltered_curL()+escRear.getFiltered_curR()+escFront.getFiltered_curL()+escFront.getFiltered_curR();

View File

@ -81,7 +81,7 @@ bool initLogging() {
void loggingLoop(unsigned long loopmillis,ESCSerialComm& escFront, ESCSerialComm& escRear) { void loggingLoop(unsigned long loopmillis,ESCSerialComm& escFront, ESCSerialComm& escRear) {
static unsigned long last_datalogging_write=loopmillis; //initialize with current time to have first log written after one interval static unsigned long last_datalogging_write=0;
static boolean logging_headerWritten=false; static boolean logging_headerWritten=false;
unsigned long logginginterval=LOGGINGINTERVAL; unsigned long logginginterval=LOGGINGINTERVAL;

View File

@ -269,6 +269,14 @@ 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(); leds();
led_update(loopmillis,escFront,escRear); //ws2812 led ring led_update(loopmillis,escFront,escRear); //ws2812 led ring
@ -319,17 +327,6 @@ void loop() {
serialCommandLoop(loopmillis,escFront,escRear); 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_min=min(looptime_duration_min,millis()-loopmillis);
looptime_duration_max=max(looptime_duration_max,millis()-loopmillis); looptime_duration_max=max(looptime_duration_max,millis()-loopmillis);

View File

@ -1,47 +1,52 @@
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
#import csv import csv
import pandas as pd
import numpy as np 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 argparse #plt.plot(x,y, label='Loaded from file!')
scattersize=5
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 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")
fig, ax1 = plt.subplots() plt.scatter(x,speed_RearL, s=scattersize, alpha=scatteralpha, label="speed_RearL")
plt.scatter(x,speed_RearR, s=scattersize, alpha=scatteralpha, label="speed_RearR")
ax2 = ax1.twinx() plt.xlabel('cmd')
plt.ylabel('speed')
plt.title('Interesting Graph\nCheck it out')
#plt.scatter(x,df['rpm_FrontL'], s=scattersize, alpha=scatteralpha, label="rpm_FrontL") plt.legend()
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() plt.show()
exit() '''
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()
'''

View File

@ -148,50 +148,51 @@ def delete_file(filename):
exit() exit()
if serialport.isOpen():
if __name__ == "__main__": establish_connection()
if serialport.isOpen():
establish_connection()
#Get File List #Get File List
filenames=get_filenames() filenames=get_filenames()
#Copy all Files #Copy all Files
failed=0
failed=0 for filename in filenames:
print("Reading file "+filename)
expectedsize=get_filesize(filename)
print("Expecting "+str(expectedsize)+" Byte")
for filename in filenames: writefilename='sdcard/'+filename
print("Reading file "+filename) receivedsize=copy_file(filename,writefilename,expectedsize)
expectedsize=get_filesize(filename)
print("Expecting "+str(expectedsize)+" Byte")
writefilename='sdcard/'+filename if (expectedsize!=receivedsize):
receivedsize=copy_file(filename,writefilename,expectedsize) print("Warning: Filesize does not match!")
failed+=1
if (expectedsize!=receivedsize): print("")
print("Warning: Filesize does not match!")
failed+=1
print("") print(str(len(filenames))+" Files copied with "+str(failed)+" failed")
print(str(len(filenames))+" Files copied with "+str(failed)+" failed")
#Delete all files #Delete all files
'''
''' log_off()
log_off() for filename in filenames:
for filename in filenames: delete_file(filename)
delete_file(filename) '''
'''
serialport.write("echo on\n".encode())
serialport.close()
serialport.write("echo on\n".encode())
serialport.close()

View File

@ -107,6 +107,8 @@ if (args.consecutive):
print("")
print(inputFilenames)
else: else:
@ -148,7 +150,7 @@ for inputFilename in inputFilenames:
linesStarttime+=_linesStarttime linesStarttime+=_linesStarttime
print("Lines in file="+str(len(inputlines))) print("Line in file="+str(len(inputlines)))
assert len(lines)==len(linesStarttime), "Length of lines and linesStarttime does not match" assert len(lines)==len(linesStarttime), "Length of lines and linesStarttime does not match"