Sensor library for quadcopter
Dependencies: MotionDriverv512
Sensor.h@0:5c097bb1300f, 2014-06-03 (annotated)
- Committer:
- oprospero
- Date:
- Tue Jun 03 07:57:32 2014 +0000
- Revision:
- 0:5c097bb1300f
- Child:
- 2:dae13ba06097
Initial Sensor Lib for quadcopter;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
oprospero | 0:5c097bb1300f | 1 | |
oprospero | 0:5c097bb1300f | 2 | #ifndef SENSOR_H |
oprospero | 0:5c097bb1300f | 3 | #define SENSOR_H |
oprospero | 0:5c097bb1300f | 4 | |
oprospero | 0:5c097bb1300f | 5 | |
oprospero | 0:5c097bb1300f | 6 | #define SAMPLE_RATE 200 |
oprospero | 0:5c097bb1300f | 7 | |
oprospero | 0:5c097bb1300f | 8 | #define M_PI 3.14159265 |
oprospero | 0:5c097bb1300f | 9 | #define RAD2DEG 180 / M_PI |
oprospero | 0:5c097bb1300f | 10 | #define GYRO_GAIN 0.061035156f |
oprospero | 0:5c097bb1300f | 11 | |
oprospero | 0:5c097bb1300f | 12 | #include "inv_mpu_dmp_motion_driver.h" |
oprospero | 0:5c097bb1300f | 13 | |
oprospero | 0:5c097bb1300f | 14 | #define DEBUG_S |
oprospero | 0:5c097bb1300f | 15 | class Sensor |
oprospero | 0:5c097bb1300f | 16 | { |
oprospero | 0:5c097bb1300f | 17 | public: |
oprospero | 0:5c097bb1300f | 18 | Sensor(); // Setup the com serial port. (tx, rx) |
oprospero | 0:5c097bb1300f | 19 | int initialize(); |
oprospero | 0:5c097bb1300f | 20 | int updateAngles(); |
oprospero | 0:5c097bb1300f | 21 | float getYaw(); |
oprospero | 0:5c097bb1300f | 22 | float getPitch(); |
oprospero | 0:5c097bb1300f | 23 | float getRoll(); |
oprospero | 0:5c097bb1300f | 24 | float getGyroYaw(); |
oprospero | 0:5c097bb1300f | 25 | float getGyroPitch(); |
oprospero | 0:5c097bb1300f | 26 | float getGyroRoll(); |
oprospero | 0:5c097bb1300f | 27 | |
oprospero | 0:5c097bb1300f | 28 | |
oprospero | 0:5c097bb1300f | 29 | private: |
oprospero | 0:5c097bb1300f | 30 | DMP_Motion_Driver dmp; |
oprospero | 0:5c097bb1300f | 31 | Quaternion q; // [w, x, y, z] quaternion container |
oprospero | 0:5c097bb1300f | 32 | VectorFloat gravity; // [x, y, z] gravity vector |
oprospero | 0:5c097bb1300f | 33 | signed char gyro_orientation[9] ; |
oprospero | 0:5c097bb1300f | 34 | float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector |
oprospero | 0:5c097bb1300f | 35 | short gyro[3]; |
oprospero | 0:5c097bb1300f | 36 | short accel[3]; |
oprospero | 0:5c097bb1300f | 37 | int packetSize; |
oprospero | 0:5c097bb1300f | 38 | uint8_t fifoBuffer[64]; // FIFO storage buffer |
oprospero | 0:5c097bb1300f | 39 | uint8_t mpuIntStatus; |
oprospero | 0:5c097bb1300f | 40 | int fifoCount; |
oprospero | 0:5c097bb1300f | 41 | |
oprospero | 0:5c097bb1300f | 42 | int mpu_initialize(); |
oprospero | 0:5c097bb1300f | 43 | int dmp_initialize(); |
oprospero | 0:5c097bb1300f | 44 | void run_self_test(); |
oprospero | 0:5c097bb1300f | 45 | |
oprospero | 0:5c097bb1300f | 46 | }; |
oprospero | 0:5c097bb1300f | 47 | |
oprospero | 0:5c097bb1300f | 48 | #endif |