An incomplete quadcopter control programme.

Dependencies:   mbed

Committer:
Gurvan
Date:
Wed Jul 17 15:58:25 2013 +0000
Revision:
0:9cb9445a11f0
Pour Zobson, fi(r)st commit.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gurvan 0:9cb9445a11f0 1 #ifndef _GURVIMU_H_
Gurvan 0:9cb9445a11f0 2 #define _GURVIMU_H_
Gurvan 0:9cb9445a11f0 3
Gurvan 0:9cb9445a11f0 4 #include "mbed.h"
Gurvan 0:9cb9445a11f0 5 #include "MPU6050.h"
Gurvan 0:9cb9445a11f0 6
Gurvan 0:9cb9445a11f0 7 class GurvIMU {
Gurvan 0:9cb9445a11f0 8 private:
Gurvan 0:9cb9445a11f0 9 //Variables
Gurvan 0:9cb9445a11f0 10 MPU6050 mpu;
Gurvan 0:9cb9445a11f0 11 float twoKp; // 2 * proportional gain (Kp)
Gurvan 0:9cb9445a11f0 12 float twoKi; // 2 * integral gain (Ki)
Gurvan 0:9cb9445a11f0 13 float integralFBx, integralFBy, integralFBz; // integral error terms scaled by Ki
Gurvan 0:9cb9445a11f0 14 float q0, q1, q2, q3; // quaternion of sensor frame relative to auxiliary frame
Gurvan 0:9cb9445a11f0 15 float ax, ay, az, gx, gy, gz;
Gurvan 0:9cb9445a11f0 16 float sample_freq;
Gurvan 0:9cb9445a11f0 17 float offset[6];
Gurvan 0:9cb9445a11f0 18 Timer timer_us;
Gurvan 0:9cb9445a11f0 19 float dt_us;
Gurvan 0:9cb9445a11f0 20 float cycle_nb;
Gurvan 0:9cb9445a11f0 21
Gurvan 0:9cb9445a11f0 22
Gurvan 0:9cb9445a11f0 23 //Functions
Gurvan 0:9cb9445a11f0 24 void getOffset();
Gurvan 0:9cb9445a11f0 25
Gurvan 0:9cb9445a11f0 26 void AHRS_update(float gx, float gy, float gz, float ax, float ay, float az);
Gurvan 0:9cb9445a11f0 27 void getQ(float * q);
Gurvan 0:9cb9445a11f0 28
Gurvan 0:9cb9445a11f0 29 public:
Gurvan 0:9cb9445a11f0 30 GurvIMU();
Gurvan 0:9cb9445a11f0 31 void init();
Gurvan 0:9cb9445a11f0 32 void getValues(float * values);
Gurvan 0:9cb9445a11f0 33 void getYawPitchRollRad(float * ypr);
Gurvan 0:9cb9445a11f0 34 void getVerticalAcceleration(float av);
Gurvan 0:9cb9445a11f0 35
Gurvan 0:9cb9445a11f0 36 };
Gurvan 0:9cb9445a11f0 37
Gurvan 0:9cb9445a11f0 38 //Fast Inverse Square Root
Gurvan 0:9cb9445a11f0 39 float invSqrt(float number);
Gurvan 0:9cb9445a11f0 40
Gurvan 0:9cb9445a11f0 41 #endif /* _GURVIMU_H_ */