# Taking a 6DOF (MPU-6050) and Calculating Acceleration Vector

Hey y'all, I have a challenge thats been on my mind and I would love some help and guidance.

I have a MPU6050 and a LSM9DS0 and I want a vector of acceleration that will help me ESTIMATE (with the aid of filters) the rough velocity and max altitude of a model rocket. (It really doesnt need to be precise)

I've got the "Jeff Rowberg" code examples of MPU-6050 (i2cdevlib-master) and I dont know how to use the quaternions, or if the math is dependent on the gravity vector in a certain direction and all that. I've also seen, and got quite confused by http://astro.square7.ch/Luftuhr/IMU/FreeIMU.cpp

THE GOAL IS TO USE A 6DOF chip in this application because they're cheap, and I might be looking to write a library to do all this nicely for a cheaper/more available chip than even the MPU6050. (wouldnt that be something!)

Consumer grade IMUs are of little to no use in a model rocket. The accelerations during takeoff are too large for most of them to measure, and the assumptions used by libraries like Jeff Rowberg's fail spectacularly.

You might take a look at David Schultz' contributions on the topic of altitude measurements.

The basic principle is calculate the attitude first, by fusing short term gyro with long-term accelerometer
data. Given the attitude the acceleration can have the gravity vector subtracted and then integrated to
get velocity, and again for position. The double integration means loads of drift though. You have to
be completely clear about which frame-of-reference each vector/quaternion is referenced too in
the calculations, and you have to switch frames-of-reference as appropriate. Everything must be calculated
in 3 dimensions

Some of the sensors have in-built processors that can do some of the work.

Overload of the accelerometer means that there is plenty of acceleration to measure, a less sophisticated
device might be able to handle the high acceleration regime - a load-cell based device might be feasible,
basically you only have high acceleration along the axis of the craft, so a single axis device is enough. A
fast sampling loop would be needed for it to capture the initial high peak accelerations and integrate them
well.

In a rocket you'll have to switch off the MEMS accelerometer input to the attitude calculation at take off and
hope for low enough gyro drift to be meaningful for the rest of the flight. Good preflight calibration of
the gyro is useful.