initial commit before ownership transfer
This commit is contained in:
66
code/reader/SensorReader.h
Executable file
66
code/reader/SensorReader.h
Executable file
@@ -0,0 +1,66 @@
|
||||
#ifndef SENSORREADER_H
|
||||
#define SENSORREADER_H
|
||||
|
||||
#include <fstream>
|
||||
|
||||
/** entry for one sensor */
|
||||
struct SensorEntry {
|
||||
|
||||
/** timestamp of occurrence */
|
||||
uint64_t ts;
|
||||
|
||||
/** sensor's number */
|
||||
int idx;
|
||||
|
||||
/** sensor data */
|
||||
std::string data;
|
||||
|
||||
};
|
||||
|
||||
/** read sensor data from CSV */
|
||||
class SensorReader {
|
||||
|
||||
private:
|
||||
|
||||
std::string file;
|
||||
std::ifstream fp;
|
||||
|
||||
public:
|
||||
|
||||
SensorReader(const std::string& file) : file(file) {
|
||||
rewind();
|
||||
}
|
||||
|
||||
bool hasNext() {
|
||||
return !fp.bad() && !fp.eof();
|
||||
}
|
||||
|
||||
/** read the next sensor entry */
|
||||
SensorEntry getNext() {
|
||||
|
||||
char delim;
|
||||
SensorEntry entry;
|
||||
|
||||
fp >> entry.ts;
|
||||
fp >> delim;
|
||||
fp >> entry.idx;
|
||||
fp >> delim;
|
||||
fp >> entry.data;
|
||||
|
||||
return entry;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/** start again */
|
||||
void rewind() {
|
||||
fp.close();
|
||||
fp.open(file);
|
||||
assert(fp.is_open());
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // SENSORREADER_H
|
||||
51
code/reader/SensorReaderStep.h
Executable file
51
code/reader/SensorReaderStep.h
Executable file
@@ -0,0 +1,51 @@
|
||||
#ifndef SENSORREADERSTEP_H
|
||||
#define SENSORREADERSTEP_H
|
||||
|
||||
#include <fstream>
|
||||
|
||||
/** entry for one sensor */
|
||||
struct SensorEntryStep {
|
||||
|
||||
/** sensor data */
|
||||
float ts; //timestamp of the step
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
/** read sensor data from CSV */
|
||||
class SensorReaderStep {
|
||||
|
||||
private:
|
||||
|
||||
std::ifstream fp;
|
||||
|
||||
public:
|
||||
|
||||
SensorReaderStep(const std::string& file) {
|
||||
fp.open(file);
|
||||
assert(fp.is_open());
|
||||
}
|
||||
|
||||
bool hasNext() {
|
||||
return !fp.bad() && !fp.eof();
|
||||
}
|
||||
|
||||
/** read the next sensor entry */
|
||||
SensorEntryStep getNext() {
|
||||
|
||||
char delim;
|
||||
SensorEntryStep entry;
|
||||
|
||||
fp >> entry.ts;
|
||||
|
||||
int i = 0;
|
||||
return entry;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // SENSORREADERSTEP_H
|
||||
56
code/reader/SensorReaderTurn.h
Executable file
56
code/reader/SensorReaderTurn.h
Executable file
@@ -0,0 +1,56 @@
|
||||
#ifndef SENSORREADERTURN_H
|
||||
#define SENSORREADERTURN_H
|
||||
|
||||
#include <fstream>
|
||||
|
||||
/** entry for one sensor */
|
||||
struct SensorEntryTurn {
|
||||
|
||||
/** timestamp of occurrence */
|
||||
float ts;
|
||||
|
||||
/** sensor data */
|
||||
float delta_heading;
|
||||
float delta_motion;
|
||||
|
||||
};
|
||||
|
||||
/** read sensor data from CSV */
|
||||
class SensorReaderTurn {
|
||||
|
||||
private:
|
||||
|
||||
std::ifstream fp;
|
||||
|
||||
public:
|
||||
|
||||
SensorReaderTurn(const std::string& file) {
|
||||
fp.open(file);
|
||||
assert(fp.is_open());
|
||||
}
|
||||
|
||||
bool hasNext() {
|
||||
return !fp.bad() && !fp.eof();
|
||||
}
|
||||
|
||||
/** read the next sensor entry */
|
||||
SensorEntryTurn getNext() {
|
||||
|
||||
char delim;
|
||||
SensorEntryTurn entry;
|
||||
|
||||
fp >> entry.ts;
|
||||
fp >> delim;
|
||||
fp >> entry.delta_heading;
|
||||
fp >> delim;
|
||||
fp >> entry.delta_motion;
|
||||
|
||||
return entry;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // SENSORREADERTURN_H
|
||||
Reference in New Issue
Block a user