This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Fusion2016/code/toni/BarometerSensorReader.h
FrankE 716b004f3c changed visualisation
added new eval code for new walkers
improved barometer (moving avg and median)
floorplan-staircase-fixes
disabled step-turn (now part of transition)
added abs-orientation-reader (for testing)
added beacons
2016-02-05 20:21:46 +01:00

63 lines
1.3 KiB
C++
Executable File

#pragma once
#include "circular.h"
#include "BarometerObservation.h"
#include "../reader/SensorReader.h"
#include <sstream>
#include <Indoor/math/MovingAVG.h>
#include <Indoor/math/MovingMedian.h>
//circular_buffer<double> measurementHistory(1000);
class BarometerSensorReader{
private:
// NOTE: median or avg?
MovingMedian<float> avg;
MovingMedian<float> avgStart;
// avg: lower size, median: bigger still fine
static constexpr int avgSize = 10;
static constexpr int startAvgSize = 10;
public:
BarometerSensorReader(): avg(avgSize), avgStart(startAvgSize) {
;
}
BarometerObservation* readBarometer(const SensorEntry& se) {
std::string tmp = se.data;
BarometerObservation* obs = new BarometerObservation();
// get the next hPa reading and average it
avg.add(std::stof(tmp));
// average the first few readings as reference
if (avgStart.getNumUsed() < startAvgSize) {
avgStart.add(std::stof(tmp));
}
// current average relative to the start-average
obs->hpa = avg.get() - avgStart.get();
// done
return obs;
}
//TODO
void readVerticalAcceleration(const SensorEntry& se){
//Problem: Koordinatensystem LinearAcceleraton ist relativ zum Telefon und nicht zum
//Weltkoordinatensystem. Brauchen die Beschleunigung nach Oben in Weltkoordinaten.
}
};