fix reading logfile with time start at zero
This commit is contained in:
parent
d4bd7c1062
commit
7f01223588
|
@ -2,6 +2,9 @@ import processing.serial.*;
|
||||||
|
|
||||||
int vis_textsize=12; //copy from Visualization class
|
int vis_textsize=12; //copy from Visualization class
|
||||||
|
|
||||||
|
//String logfile_name="LOG00008_rumfahren_neu.TXT";
|
||||||
|
String logfile_name="LOG00180_random.TXT";
|
||||||
|
|
||||||
boolean useSerial=false; //false=read from csv log, true=read from serial port
|
boolean useSerial=false; //false=read from csv log, true=read from serial port
|
||||||
Serial serial;
|
Serial serial;
|
||||||
String serialString=""; //last read string
|
String serialString=""; //last read string
|
||||||
|
@ -78,7 +81,7 @@ void setup() {
|
||||||
serialString = serial.readStringUntil(serial_endchar);
|
serialString = serial.readStringUntil(serial_endchar);
|
||||||
serialString = null;
|
serialString = null;
|
||||||
}else{
|
}else{
|
||||||
logdata = loadTable("LOG00008_rumfahren_neu.TXT", "header, csv");
|
logdata = loadTable(logfile_name, "header, csv");
|
||||||
|
|
||||||
println("loaded "+logdata.getRowCount()+" lines. Times: "+logdata.getRow(0).getFloat("time")+"s to "+logdata.getRow(logdata.getRowCount()-1).getFloat("time")+"s");
|
println("loaded "+logdata.getRowCount()+" lines. Times: "+logdata.getRow(0).getFloat("time")+"s to "+logdata.getRow(logdata.getRowCount()-1).getFloat("time")+"s");
|
||||||
}
|
}
|
||||||
|
@ -242,7 +245,7 @@ void draw() {
|
||||||
throttle=row.getInt("throttle");
|
throttle=row.getInt("throttle");
|
||||||
brake=row.getInt("brake");
|
brake=row.getInt("brake");
|
||||||
|
|
||||||
if (loopmillis-nextTime>1000) {//too much behind
|
if (loopmillis-nextTime>1000 && nextTime>lastTimeData) {//too much behind
|
||||||
long _timestep=nextTime-lastTimeData; //approximated time step
|
long _timestep=nextTime-lastTimeData; //approximated time step
|
||||||
nextID+=(loopmillis-nextTime)/_timestep* 0.9; //fast forward estimated time steps
|
nextID+=(loopmillis-nextTime)/_timestep* 0.9; //fast forward estimated time steps
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue