fixed some issues

added new pose/turn detections
new helper classes
define-flags for libEigen
This commit is contained in:
2018-09-04 10:49:00 +02:00
parent f990485d44
commit 857d7a1553
51 changed files with 2149 additions and 207 deletions

View File

@@ -3,28 +3,67 @@
#include <cmath>
#include "../../math/Floatingpoint.h"
/** data received from a barometer sensor */
struct BarometerData {
float hPa;
FPDefault hPa;
explicit BarometerData() : hPa(0) {;}
explicit BarometerData(const float hPa) : hPa(hPa) {;}
explicit BarometerData(const FPDefault hPa) : hPa(hPa) {;}
/** valid data? */
bool isValid() const {
return hPa == hPa;
return !std::isnan(hPa);
}
bool operator == (const BarometerData& o ) const {
return EQ_OR_NAN(hPa, o.hPa);
}
public:
static constexpr double R = 8.31447; // universal gas constant for air, newton meter / mol kelvin
static constexpr double L = 0.0065; // standard temperature lapse rate, degree kelven per meter
static constexpr double g = 9.80665; // gravity constant, meter per square second
static constexpr double M = 0.0289644; // molar mass for dry air, kg / mol
static constexpr double P0 = 1013.25; // pressure at mean sea level, hPa
static constexpr double T0 = 288.15; // temperature at mean sea level, kelvin
/** hPa->meter assuming a constant 1013.25 at 0m as reference */
static FPDefault hpaToMeter(const FPDefault pressure) {
return static_cast<FPDefault>(
(T0/L) * (std::pow(static_cast<FPDouble>(pressure)/P0, -(R*L)/(g*M))-1.0)
);
}
/** hPa->meter by using the given pressure pRef at hRef as reference */
static FPDefault hpaToMeter(const FPDefault pressure, const FPDefault PRef, const FPDefault hRef) {
return static_cast<FPDefault>(
hRef + (T0/L) * (std::pow(static_cast<FPDouble>(pressure)/PRef, -(R*L)/(g*M))-1.0)
);
}
/** meter->hPa assuming a constant 1013.25 at 0m as reference */
static FPDefault meterTohPa(const FPDefault altitude) {
return static_cast<FPDefault>(
P0 * std::pow(T0 / (T0+L*altitude), (g*M)/(R*L))
);
}
/** meter->hPa by using the given pressure pRef at hRef as reference */
static FPDefault meterTohPa(const FPDefault altitude, const FPDefault PRef, const FPDefault hRef) {
return static_cast<FPDefault>(
PRef * std::pow(T0 / (T0+L*(altitude-hRef)), (g*M)/(R*L))
);
}
private:
static inline bool EQ_OR_NAN(const float a, const float b) {return (a==b) || ( (a!=a) && (b!=b) );}
static inline bool EQ_OR_NAN(const FPDefault a, const FPDefault b) {return (a==b) || ( (a!=a) && (b!=b) );}
};