43 lines
924 B
C++
43 lines
924 B
C++
#ifndef ORIENTATIONSENSORREADER_H
|
|
#define ORIENTATIONSENSORREADER_H
|
|
|
|
|
|
#include "../reader/SensorReader.h"
|
|
#include "OrientationObservation.h"
|
|
|
|
#include <cassert>
|
|
|
|
class OrientationSensorReader {
|
|
|
|
public:
|
|
|
|
/** get wifi observation data from one CSV entry */
|
|
static OrientationObservation read(const SensorEntry& se) {
|
|
|
|
std::string tmp = se.data;
|
|
OrientationObservation obs;
|
|
|
|
size_t pos1 = tmp.find(';');
|
|
size_t pos2 = tmp.find(';', pos1+1);
|
|
size_t pos3 = tmp.find(';', pos2+1);
|
|
|
|
assert(pos1 != std::string::npos);
|
|
assert(pos2 != std::string::npos);
|
|
assert(pos3 != std::string::npos);
|
|
|
|
const std::string s1 = tmp.substr(0, pos1);
|
|
const std::string s2 = tmp.substr(pos1+1, pos2-pos1-1);
|
|
const std::string s3 = tmp.substr(pos2+1, pos3-pos2-1);
|
|
|
|
obs.values[0] = std::stof(s1);
|
|
obs.values[1] = std::stof(s2);
|
|
obs.values[2] = std::stof(s3);
|
|
|
|
return obs;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif // ORIENTATIONSENSORREADER_H
|