Implemented first Hangar-Service
Dependencies: CalibrateMagneto QuaternionMath
Fork of SML2 by
SensorFusion.h@20:503cbe360419, 2015-04-09 (annotated)
- Committer:
- pvaibhav
- Date:
- Thu Apr 09 09:51:51 2015 +0000
- Revision:
- 20:503cbe360419
- Parent:
- 17:e9d42864c8a1
- Child:
- 21:5a0c9406e119
WIP Refactor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pvaibhav | 15:4488660e1a3b | 1 | #ifndef _H_SENSORFUSION_H |
pvaibhav | 15:4488660e1a3b | 2 | #define _H_SENSORFUSION_H |
pvaibhav | 15:4488660e1a3b | 3 | |
pvaibhav | 15:4488660e1a3b | 4 | #include "I2CPeripheral.h" |
pvaibhav | 15:4488660e1a3b | 5 | #include "Magnetometer.h" |
pvaibhav | 15:4488660e1a3b | 6 | #include "Accelerometer.h" |
pvaibhav | 15:4488660e1a3b | 7 | #include "Gyroscope.h" |
pvaibhav | 15:4488660e1a3b | 8 | #include "Quaternion.h" |
pvaibhav | 15:4488660e1a3b | 9 | |
pvaibhav | 15:4488660e1a3b | 10 | class SensorFusion : public Sensor::Delegate |
pvaibhav | 15:4488660e1a3b | 11 | { |
pvaibhav | 15:4488660e1a3b | 12 | public: |
pvaibhav | 20:503cbe360419 | 13 | class Delegate |
pvaibhav | 20:503cbe360419 | 14 | { |
pvaibhav | 20:503cbe360419 | 15 | virtual void sensorTick(Vector3 fused, Vector3 accel, Vector3 magneto, Vector3 gyro, Quaternion q) = 0; |
pvaibhav | 20:503cbe360419 | 16 | }; |
pvaibhav | 20:503cbe360419 | 17 | |
pvaibhav | 15:4488660e1a3b | 18 | SensorFusion(I2C &i2c); |
pvaibhav | 20:503cbe360419 | 19 | void setDelegate(Delegate &d); |
pvaibhav | 15:4488660e1a3b | 20 | |
pvaibhav | 15:4488660e1a3b | 21 | bool start(); |
pvaibhav | 15:4488660e1a3b | 22 | void stop(); |
pvaibhav | 15:4488660e1a3b | 23 | |
pvaibhav | 15:4488660e1a3b | 24 | virtual void sensorUpdate(Vector3 gyro_degrees); // gyro's callback |
pvaibhav | 15:4488660e1a3b | 25 | |
pvaibhav | 15:4488660e1a3b | 26 | private: |
pvaibhav | 20:503cbe360419 | 27 | Delegate* delegate; |
pvaibhav | 15:4488660e1a3b | 28 | Accelerometer accel; |
pvaibhav | 15:4488660e1a3b | 29 | Gyroscope gyro; |
pvaibhav | 15:4488660e1a3b | 30 | Magnetometer magneto; |
pvaibhav | 15:4488660e1a3b | 31 | Quaternion q; |
pvaibhav | 15:4488660e1a3b | 32 | float deltat, beta; |
pvaibhav | 15:4488660e1a3b | 33 | void updateFilter(float ax, float ay, float az, float gx, float gy, float gz, float mx, float my, float mz); |
pvaibhav | 17:e9d42864c8a1 | 34 | Vector3 eulerAngles(Quaternion const &q) const; |
pvaibhav | 15:4488660e1a3b | 35 | }; |
pvaibhav | 15:4488660e1a3b | 36 | |
pvaibhav | 15:4488660e1a3b | 37 | #endif |