Sensor library for quadcopter
Dependencies: MotionDriverv512
Sensor.h@3:e658293d4b83, 2014-10-15 (annotated)
- Committer:
- oprospero
- Date:
- Wed Oct 15 04:59:43 2014 +0000
- Revision:
- 3:e658293d4b83
- Parent:
- 2:dae13ba06097
- Child:
- 4:f817736140b6
added reset
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 | 2:dae13ba06097 | 11 | //#define GYRO_GAIN 0.030517578f |
oprospero | 2:dae13ba06097 | 12 | //#define GYRO_GAIN 0.015258789f |
oprospero | 2:dae13ba06097 | 13 | //#define GYRO_GAIN 0.007629394f |
oprospero | 0:5c097bb1300f | 14 | |
oprospero | 0:5c097bb1300f | 15 | #include "inv_mpu_dmp_motion_driver.h" |
oprospero | 0:5c097bb1300f | 16 | |
oprospero | 0:5c097bb1300f | 17 | #define DEBUG_S |
oprospero | 0:5c097bb1300f | 18 | class Sensor |
oprospero | 0:5c097bb1300f | 19 | { |
oprospero | 0:5c097bb1300f | 20 | public: |
oprospero | 0:5c097bb1300f | 21 | Sensor(); // Setup the com serial port. (tx, rx) |
oprospero | 0:5c097bb1300f | 22 | int initialize(); |
oprospero | 3:e658293d4b83 | 23 | void reset(); |
oprospero | 0:5c097bb1300f | 24 | int updateAngles(); |
oprospero | 0:5c097bb1300f | 25 | float getYaw(); |
oprospero | 0:5c097bb1300f | 26 | float getPitch(); |
oprospero | 0:5c097bb1300f | 27 | float getRoll(); |
oprospero | 0:5c097bb1300f | 28 | float getGyroYaw(); |
oprospero | 0:5c097bb1300f | 29 | float getGyroPitch(); |
oprospero | 0:5c097bb1300f | 30 | float getGyroRoll(); |
oprospero | 0:5c097bb1300f | 31 | |
oprospero | 0:5c097bb1300f | 32 | |
oprospero | 0:5c097bb1300f | 33 | private: |
oprospero | 0:5c097bb1300f | 34 | DMP_Motion_Driver dmp; |
oprospero | 0:5c097bb1300f | 35 | Quaternion q; // [w, x, y, z] quaternion container |
oprospero | 0:5c097bb1300f | 36 | VectorFloat gravity; // [x, y, z] gravity vector |
oprospero | 0:5c097bb1300f | 37 | signed char gyro_orientation[9] ; |
oprospero | 0:5c097bb1300f | 38 | float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector |
oprospero | 0:5c097bb1300f | 39 | short gyro[3]; |
oprospero | 0:5c097bb1300f | 40 | short accel[3]; |
oprospero | 0:5c097bb1300f | 41 | int packetSize; |
oprospero | 0:5c097bb1300f | 42 | uint8_t fifoBuffer[64]; // FIFO storage buffer |
oprospero | 0:5c097bb1300f | 43 | uint8_t mpuIntStatus; |
oprospero | 0:5c097bb1300f | 44 | int fifoCount; |
oprospero | 0:5c097bb1300f | 45 | |
oprospero | 0:5c097bb1300f | 46 | int mpu_initialize(); |
oprospero | 0:5c097bb1300f | 47 | int dmp_initialize(); |
oprospero | 0:5c097bb1300f | 48 | void run_self_test(); |
oprospero | 0:5c097bb1300f | 49 | |
oprospero | 0:5c097bb1300f | 50 | }; |
oprospero | 0:5c097bb1300f | 51 | |
oprospero | 0:5c097bb1300f | 52 | #endif |