Calculating angle using MPU6050 sensor with kalman filter method
Main resource of this code from : here
the resource explains clearly how does the filter work step by step with the code example in C++
List of depedencies :
- kalman filter libraries from TKJElectronics
- I2Cdev from jeff rowberg
- MPU6050 from jeff rowberg
and one built-in library :
- Wire
- angleKalman() : This one create your kalman instance.
- setUpSensor() : This method is kick starting your instance.
- readSensor() : This method read for 6 axis originally from MPU6050. The value expected should be in deg/s and g.
- calculateRollPitch() : This converts your deg/s and g into Roll and Pitch according to RPY inertial system.
- setStartingAngle() : This one set your initial angle.
- calculateDeltaTime(dt) : Calculating the dt. You have to create your own dt var inside your code then pass it to the method.
- calculateGyroRate() : This method normalize your gyroscope measurement from deg/s to deg.
- calculateKalman() : This is the main star of this class. This calculate the degree of Roll and Pitch using kalman. Both Roll and Pitch already calculated here.
- calibrateSensor(double ax_offset, double ay_offset, double az_offset,double gx_offset, double gy_offset, double gz_offset) : Use this code and plug the result.
- if you see BMP methods, don't bother. Still on development process.