updates the visualisation
removed obsolte parts fixed baromter stuff worked on eval added ground-truth
This commit is contained in:
@@ -5,25 +5,29 @@
|
||||
#include "../reader/SensorReader.h"
|
||||
#include <sstream>
|
||||
|
||||
#include <Indoor/math/MovingAVG.h>
|
||||
|
||||
//circular_buffer<double> measurementHistory(1000);
|
||||
|
||||
|
||||
class BarometerSensorReader{
|
||||
|
||||
private:
|
||||
circular_buffer<double> measurementHistory;
|
||||
// circular_buffer<double> measurementHistory;
|
||||
|
||||
MovingAVG<float> avg;
|
||||
|
||||
public:
|
||||
|
||||
BarometerSensorReader(){
|
||||
if(!USE_STATIC_CIRCULAR_BUFFERING){
|
||||
//8.33min
|
||||
measurementHistory.reserve(10000);
|
||||
}
|
||||
else{
|
||||
//30 * 500ms = 1,5s
|
||||
measurementHistory.reserve(30);
|
||||
}
|
||||
BarometerSensorReader(): avg(3) {
|
||||
// if(!USE_STATIC_CIRCULAR_BUFFERING){
|
||||
// //8.33min
|
||||
// measurementHistory.reserve(10000);
|
||||
// }
|
||||
// else{
|
||||
// //30 * 500ms = 1,5s
|
||||
// measurementHistory.reserve(30);
|
||||
// }
|
||||
}
|
||||
|
||||
BarometerObservation* readBarometer(const SensorEntry& se) {
|
||||
@@ -31,52 +35,63 @@ public:
|
||||
std::string tmp = se.data;
|
||||
BarometerObservation* obs = new BarometerObservation();
|
||||
|
||||
//Read the hPa
|
||||
double hPa = stod(tmp);
|
||||
// get the next hPa reading and average it
|
||||
avg.add(stod(tmp));
|
||||
const double hPa = avg.get();
|
||||
|
||||
// load the measurement at current time into the history
|
||||
double currentMeasurement = hPa - measurementHistory[0];
|
||||
// everything realtive to the first measurement
|
||||
static double first_hPa = 0;
|
||||
if (avg.getNumUsed() < avg.getSize()) {first_hPa = avg.get();}
|
||||
|
||||
if(USE_BAROMETER_SMOOTHING_RC_LOWPASS){
|
||||
obs->hpa = hPa - first_hPa;
|
||||
|
||||
//smoothing with alpha value
|
||||
if(measurementHistory.size() > 1){
|
||||
double alpha = 0.1;
|
||||
double lastMeasurement = measurementHistory[measurementHistory.size() - 1];
|
||||
currentMeasurement = (alpha * currentMeasurement) + ((1.0 - alpha) * lastMeasurement);
|
||||
|
||||
obs->hpa = currentMeasurement;
|
||||
}else{
|
||||
obs->hpa = 0;
|
||||
}
|
||||
|
||||
measurementHistory.push_back(currentMeasurement);
|
||||
}
|
||||
else if (USE_BAROMETER_SMOOTHING_HEAD_TAIL){
|
||||
|
||||
currentMeasurement = hPa;
|
||||
measurementHistory.push_back(currentMeasurement);
|
||||
|
||||
// calculate the relative air pressure by getting the mean of the first and last three entrys of the history
|
||||
// and subtract them.
|
||||
if (measurementHistory.size() > 5){
|
||||
double meanTail = (measurementHistory[0] + measurementHistory[1] + measurementHistory[2]) / 3.0;
|
||||
double meanHead = (measurementHistory[measurementHistory.size() - 1] + measurementHistory[measurementHistory.size() - 2] + measurementHistory[measurementHistory.size() - 3]) / 3.0;
|
||||
|
||||
obs->hpa = meanHead - meanTail;
|
||||
}
|
||||
else{
|
||||
obs->hpa = 0;
|
||||
}
|
||||
}
|
||||
else //no data smoothing
|
||||
{
|
||||
measurementHistory.push_back(currentMeasurement);
|
||||
obs->hpa = currentMeasurement;
|
||||
}
|
||||
std::cout << obs->hpa << std::endl;
|
||||
|
||||
// done
|
||||
return obs;
|
||||
|
||||
|
||||
|
||||
// if(USE_BAROMETER_SMOOTHING_RC_LOWPASS){
|
||||
|
||||
// //smoothing with alpha value
|
||||
// if(measurementHistory.size() > 1){
|
||||
// double alpha = 0.1;
|
||||
// double lastMeasurement = measurementHistory[measurementHistory.size() - 1];
|
||||
// currentMeasurement = (alpha * currentMeasurement) + ((1.0 - alpha) * lastMeasurement);
|
||||
|
||||
// obs->hpa = currentMeasurement;
|
||||
// }else{
|
||||
// obs->hpa = 0;
|
||||
// }
|
||||
|
||||
// measurementHistory.push_back(currentMeasurement);
|
||||
// }
|
||||
// else if (USE_BAROMETER_SMOOTHING_HEAD_TAIL){
|
||||
|
||||
// currentMeasurement = hPa;
|
||||
// measurementHistory.push_back(currentMeasurement);
|
||||
|
||||
// // calculate the relative air pressure by getting the mean of the first and last three entrys of the history
|
||||
// // and subtract them.
|
||||
// if (measurementHistory.size() > 5){
|
||||
// double meanTail = (measurementHistory[0] + measurementHistory[1] + measurementHistory[2]) / 3.0;
|
||||
// double meanHead = (measurementHistory[measurementHistory.size() - 1] + measurementHistory[measurementHistory.size() - 2] + measurementHistory[measurementHistory.size() - 3]) / 3.0;
|
||||
|
||||
// obs->hpa = meanHead - meanTail;
|
||||
// }
|
||||
// else{
|
||||
// obs->hpa = 0;
|
||||
// }
|
||||
// }
|
||||
// else //no data smoothing
|
||||
// {
|
||||
// measurementHistory.push_back(currentMeasurement);
|
||||
// obs->hpa = currentMeasurement;
|
||||
// }
|
||||
|
||||
// return obs;
|
||||
|
||||
}
|
||||
|
||||
//TODO
|
||||
|
||||
Reference in New Issue
Block a user