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
Indoor/sensors/imu/GyroscopeData.h
frank 857d7a1553 fixed some issues
added new pose/turn detections
new helper classes
define-flags for libEigen
2018-09-04 10:49:00 +02:00

50 lines
971 B
C++

#ifndef GYROSCOPEDATA_H
#define GYROSCOPEDATA_H
#include <cmath>
#include <sstream>
#include "../../math/Floatingpoint.h"
/**
* data received from a gyroscope sensor
* IN RADIANS!
*/
struct GyroscopeData {
FPDefault x;
FPDefault y;
FPDefault z;
GyroscopeData() : x(0), y(0), z(0) {;}
/** ctor from RADIANS */
GyroscopeData(const FPDefault x, const FPDefault y, const FPDefault z) : x(x), y(y), z(z) {;}
float magnitude() const {
return std::sqrt( x*x + y*y + z*z );
}
std::string asString() const {
std::stringstream ss;
ss << "(" << x << "," << y << "," << z << ")";
return ss.str();
}
bool isValid() const {
return (x == x) && (y == y) && (z == z);
}
bool operator == (const GyroscopeData& o ) const {
return EQ_OR_NAN(x, o.x) &&
EQ_OR_NAN(y, o.y) &&
EQ_OR_NAN(z, o.z);
}
private:
static inline bool EQ_OR_NAN(const FPDefault a, const FPDefault b) {return (a==b) || ( (a!=a) && (b!=b) );}
};
#endif // GYROSCOPEDATA_H