Implemented first Hangar-Service

Dependencies:   CalibrateMagneto QuaternionMath

Fork of SML2 by TobyRich GmbH

SensorFusion.h

Committer:
pvaibhav
Date:
2015-03-26
Revision:
17:e9d42864c8a1
Parent:
15:4488660e1a3b
Child:
20:503cbe360419

File content as of revision 17:e9d42864c8a1:

#ifndef _H_SENSORFUSION_H
#define _H_SENSORFUSION_H

#include "I2CPeripheral.h"
#include "Magnetometer.h"
#include "Accelerometer.h"
#include "Gyroscope.h"
#include "Quaternion.h"

class SensorFusion : public Sensor::Delegate
{
public:
    SensorFusion(I2C &i2c);

    bool start();
    void stop();

    virtual void sensorTick(Vector3 fused, Vector3 accel, Vector3 magneto, Vector3 gyro, Quaternion q) = 0;
    virtual void sensorUpdate(Vector3 gyro_degrees); // gyro's callback

private:
    Accelerometer accel;
    Gyroscope gyro;
    Magnetometer magneto;
    Quaternion q;
    float deltat, beta;
    void updateFilter(float ax, float ay, float az, float gx, float gy, float gz, float mx, float my, float mz);
    Vector3 eulerAngles(Quaternion const &q) const;
};

#endif