Sensor library for quadcopter
Dependencies: MotionDriverv512
Diff: Sensor.h
- Revision:
- 0:5c097bb1300f
- Child:
- 2:dae13ba06097
diff -r 000000000000 -r 5c097bb1300f Sensor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sensor.h Tue Jun 03 07:57:32 2014 +0000 @@ -0,0 +1,48 @@ + +#ifndef SENSOR_H +#define SENSOR_H + + +#define SAMPLE_RATE 200 + +#define M_PI 3.14159265 +#define RAD2DEG 180 / M_PI +#define GYRO_GAIN 0.061035156f + +#include "inv_mpu_dmp_motion_driver.h" + +#define DEBUG_S +class Sensor +{ + public: + Sensor(); // Setup the com serial port. (tx, rx) + int initialize(); + int updateAngles(); + float getYaw(); + float getPitch(); + float getRoll(); + float getGyroYaw(); + float getGyroPitch(); + float getGyroRoll(); + + + private: + DMP_Motion_Driver dmp; + Quaternion q; // [w, x, y, z] quaternion container + VectorFloat gravity; // [x, y, z] gravity vector + signed char gyro_orientation[9] ; + float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector + short gyro[3]; + short accel[3]; + int packetSize; + uint8_t fifoBuffer[64]; // FIFO storage buffer + uint8_t mpuIntStatus; + int fifoCount; + + int mpu_initialize(); + int dmp_initialize(); + void run_self_test(); + +}; + +#endif