read acceleration and angler ratio from mpu6050 and estimate pitch and roll angle

Dependencies:   mbed

Committer:
ojan
Date:
Mon Apr 20 14:54:55 2015 +0000
Revision:
2:4a6b46653abf
Child:
3:40559ebef0f1
?????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ojan 2:4a6b46653abf 1 #pragma once
ojan 2:4a6b46653abf 2 #include "Matrix.h"
ojan 2:4a6b46653abf 3 #include "ErrorLogger.h"
ojan 2:4a6b46653abf 4
ojan 2:4a6b46653abf 5 class Vector {
ojan 2:4a6b46653abf 6 public:
ojan 2:4a6b46653abf 7 Vector(int dim);
ojan 2:4a6b46653abf 8 ~Vector();
ojan 2:4a6b46653abf 9 Vector(const Vector& v);
ojan 2:4a6b46653abf 10
ojan 2:4a6b46653abf 11 Vector& operator=(const Vector& v);
ojan 2:4a6b46653abf 12 Vector& operator*=(float c);
ojan 2:4a6b46653abf 13 Vector& operator/=(float c);
ojan 2:4a6b46653abf 14 Vector& operator+=(const Vector& v);
ojan 2:4a6b46653abf 15 Vector& operator-=(const Vector& v);
ojan 2:4a6b46653abf 16
ojan 2:4a6b46653abf 17 void SetComp(int dimNo, float val);
ojan 2:4a6b46653abf 18 float GetNorm() const;
ojan 2:4a6b46653abf 19 Vector GetUnit() const;
ojan 2:4a6b46653abf 20
ojan 2:4a6b46653abf 21 inline int GetDim() const {
ojan 2:4a6b46653abf 22 return dim;
ojan 2:4a6b46653abf 23 }
ojan 2:4a6b46653abf 24
ojan 2:4a6b46653abf 25 inline const float* GetpComponents() const {
ojan 2:4a6b46653abf 26 return (const float*)components;
ojan 2:4a6b46653abf 27 }
ojan 2:4a6b46653abf 28
ojan 2:4a6b46653abf 29 inline float GetComp(int dimNo) const {
ojan 2:4a6b46653abf 30 if (dimNo > dim) AbortWithMsg("Index Out of Bounds Error !!");
ojan 2:4a6b46653abf 31 return components[dimNo-1];
ojan 2:4a6b46653abf 32 }
ojan 2:4a6b46653abf 33
ojan 2:4a6b46653abf 34 void CleanUp();
ojan 2:4a6b46653abf 35
ojan 2:4a6b46653abf 36 private:
ojan 2:4a6b46653abf 37 int dim;
ojan 2:4a6b46653abf 38 float* components;
ojan 2:4a6b46653abf 39
ojan 2:4a6b46653abf 40 Vector& operator*=(const Matrix& m);
ojan 2:4a6b46653abf 41 Vector& operator*=(const Vector& m);
ojan 2:4a6b46653abf 42 };
ojan 2:4a6b46653abf 43
ojan 2:4a6b46653abf 44 Vector operator+(const Vector& lhv, const Vector& rhv);
ojan 2:4a6b46653abf 45 Vector operator-(const Vector& lhv, const Vector& rhv);
ojan 2:4a6b46653abf 46 Vector Cross(const Vector& lhv, const Vector& rhv);
ojan 2:4a6b46653abf 47 Vector operator*(const float c, const Vector& rhv);
ojan 2:4a6b46653abf 48 Vector operator*(const Vector& lhv, const float c);
ojan 2:4a6b46653abf 49 Vector operator*(const Matrix& lhm, const Vector& rhv);
ojan 2:4a6b46653abf 50 Vector operator*(const Vector& lhv, const Matrix& rhm);
ojan 2:4a6b46653abf 51 float operator*(const Vector& lhv, const Vector& rhv);
ojan 2:4a6b46653abf 52